rdflib.js icon indicating copy to clipboard operation
rdflib.js copied to clipboard

Fetching data islands in RDFa too zealous

Open doriantaylor opened this issue 6 months ago • 3 comments

Hi,

I have RDFa markup that has <script> tags that have a type that is Parsable but they have src attributes so there's nothing in the bodies. The following code thus blows up:

https://github.com/linkeddata/rdflib.js/blob/85a72c83072f37ce2b31a2545d3d70c51aa18d89/reference/fetcher-classes.js#L117

Would it be possible to add an option to Fetcher.load to turn this behaviour off? Or otherwise skip over it if there's an src attribute, or otherwise have it no-op or wrap in a try block or something?

doriantaylor avatar Jun 29 '25 17:06 doriantaylor

That makes sense. The code should do something like textContent.trim().length == 0 before committing to parse.

Dorian, if your script src is referring to JavaScript, you can omit the type attribute ( https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type ) - perhaps that's of some help for the time being.

csarven avatar Jun 29 '25 20:06 csarven

https://github.com/linkeddata/rdflib.js/pull/693

csarven avatar Jun 29 '25 20:06 csarven

nah it's my lazy bastard transclusion mechanism. The thing that's spitting that out though (or rather its neighbours; warning: SLOW) has content negotiation with a JSON-LD variant so just added another variant to the one that was tripping up.

doriantaylor avatar Jun 29 '25 20:06 doriantaylor