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

bug due to querySelector(All) assumptions #49

Open
Treora opened this issue Mar 9, 2020 · 0 comments
Open

bug due to querySelector(All) assumptions #49

Treora opened this issue Mar 9, 2020 · 0 comments
Labels

Comments

@Treora
Copy link
Contributor

Treora commented Mar 9, 2020

At least one bug is caused by using querySelectorAll and assuming it only returns HTML elements:

const linkElements = Array.from(rootElement.querySelectorAll('a, area'))
linkElements
        .filter(element => element.href.startsWith('javascript:'))

The HTML <a> and <area> elements guarantee that .href is a string (an empty string if the attribute is absent). But SVG’s <a> element does not, making these lines throw an error (discovered in the wild).

Need to check all uses of querySelector(All). Maybe we could…

  • do an instanceof check on the resulting elements;
  • or just check for the existence of the href attribute (or should we avoid interfering with unexpected namespaces?);
  • or we could select the elements in some other way, e.g. rootElement.getElementsByTagNameNS('http://www.w3.org/1999/xhtml','a').

Seperately (in scope of issue #27) we should check if javascript: URLs should be removed from SVG’s xlinks.

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

No branches or pull requests

1 participant