Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getNamedItem discrepancy between browser and deno_dom 0.1.36 #133

Open
cscheid opened this issue Feb 9, 2023 · 3 comments
Open

getNamedItem discrepancy between browser and deno_dom 0.1.36 #133

cscheid opened this issue Feb 9, 2023 · 3 comments

Comments

@cscheid
Copy link

cscheid commented Feb 9, 2023

Note the discrepancy with case sensitivity of some attributes (specifically, viewbox vs viewBox).

On Google Chrome:

> (new DOMParser()).parseFromString('<svg width="371pt" height="247pt" viewbox="0.00 0.00 370.99 246.71"></svg>', 'text/html').querySelector("svg").attributes.getNamedItem("viewBox")
viewBox=​"0.00 0.00 370.99 246.71"

> (new DOMParser()).parseFromString('<svg width="371pt" height="247pt" viewbox="0.00 0.00 370.99 246.71"></svg>', 'text/html').querySelector("svg").attributes.getNamedItem("viewbox")
null

On deno_dom 0.1.36:

> import {
  DOMParser,
  Element,
} from "https://deno.land/x/deno_dom/deno-dom-wasm.ts";
Download ⠧ https://deno.land/x/deno_dom/deno-dom-wasm.ts
Warning Implicitly using latest version (v0.1.36-alpha) for https://deno.land/x/deno_dom/deno-dom-wasm.ts

> (new DOMParser()).parseFromString('<svg width="371pt" height="247pt" viewbox="0.00 0.00 370.99 246.71"></svg>', 'text/html').querySelector("svg").attributes.getNamedItem("viewBox")
null

> (new DOMParser()).parseFromString('<svg width="371pt" height="247pt" viewbox="0.00 0.00 370.99 246.71"></svg>', 'text/html').querySelector("svg").attributes.getNamedItem("viewbox")
EventTarget {
  childNodes: [],
  parentNode: null,
  parentElement: null,
  _ancestors: Set {},
  nodeName: "viewbox",
  nodeType: 2,
  [Symbol()]: {
    assignedSlot: false,
    hasActivationBehavior: false,
    host: null,
    listeners: {},
    mode: ""
  },
  [Symbol("[[webidl.brand]]")]: Symbol("[[webidl.brand]]")
}
@b-fuze
Copy link
Owner

b-fuze commented Feb 9, 2023

That is caused by Deno DOM not yet being able to produce XML nodes (which includes embedded XML documents as in your case) properly...

I just checked the parser and html5ever does knows that an SVG tag should be parsed as an embedded XML document... This might be easier to fix than I thought 🤔

image

@cscheid
Copy link
Author

cscheid commented Feb 9, 2023

fwiw, this used to work on 0.1.20. (Sorry that I don't have a tighter bracket for your bisecting...)

@b-fuze
Copy link
Owner

b-fuze commented Feb 9, 2023

I'll look into it, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants