Bug 255764
| Summary: | Support of multiple contexts for JSON+LD content in script element (square brackets) | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Karl Dubost <karlcow> |
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED MOVED | ||
| Severity: | Normal | CC: | ap, mark.lam, vkhomyackov, webkit-bug-importer, xidorn-webkit, ysuzuki |
| Priority: | P2 | Keywords: | BrowserCompat, CanvaBug, InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| URL: | https://w3c.github.io/json-ld-syntax/#advanced-context-usage | ||
Karl Dubost
The advanced context usage for JSON+LD authorizes the use of an array.
https://w3c.github.io/json-ld-syntax/#advanced-context-usage
Nothing is said in the section about a restriction in embedding JSON+LD in html documents
https://w3c.github.io/json-ld-syntax/#embedding-json-ld-in-html-documents
So the square bracket syntax is failing in Safari:
```
data:text/html,%20%20%20%20<script%20type="application/ld+json">[{"@context":%20"https://schema.org"}]</script>
```
with
```
TypeError: undefined is not an object (evaluating 'r["@context"].toLowerCase')
```
while this is working.
```
<script type="application/ld+json">{"@context": "https://schema.org"}</script>
```
The minimal test case to reproduce the issue is
```
<script type="application/ld+json">[]</script>
```
In both Chrome and Firefox, this syntax is accepted.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/108352610>
Karl Dubost
I have moved the radar to Safari, as this is not handled on WebKit side, but Safari side.
Xidorn Quan
Karl, is there anywhere the progress of the issue can be tracked publicly?
Karl Dubost
Oh yes I dropped the ball about that.
So one side WebKit doesn't suport JSON+LD in the engine.
And the other Safari just needs the data as-is, so basically not to evaluate but just load it.
Let see if there's an intermediary solution here.
Karl Dubost
Xidorn,
Do you know about an app or a current website with a usage for this construct/syntax?
Xidorn Quan
Yes, Canva's logout templates page currently uses this syntax: https://www.canva.com/templates/ (If you have Canva account, you need to logout or use private mode to access).
I think we are fixing it, so I can't say how long it would keep being like it. Its current content is:
```
[{"@context":"https:\u002F\u002Fschema.org","@type":"WebSite","url":"https:\u002F\u002Fwww.canva.com\u002Ftemplates\u002F","potentialAction":[{"@type":"SearchAction","target":"https:\u002F\u002Fwww.canva.com\u002Ftemplates\u002Ftemplates\u002F?query={search_term_string}","query-input":"required name=search_term_string"}]}]
```
Karl Dubost
Thanks a lot!
Karl Dubost
Xidorn, this is still being discussed to find the origin of the issue and if it is something to fix on Safari side.
Karl Dubost
Xidorn, this is still being discussed to find the origin of the issue and if it is something to fix on Safari side.
Victor
Is there any progress on that issue?