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

A way for createAttribute() to bypass XML Name validation in HTML documents #769

Open
platosha opened this issue Jun 26, 2019 · 2 comments · May be fixed by #1079
Open

A way for createAttribute() to bypass XML Name validation in HTML documents #769

platosha opened this issue Jun 26, 2019 · 2 comments · May be fixed by #1079
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest

Comments

@platosha
Copy link

createAttribute(localName) and other attribute creating methods (setAttribute and such) require attribute name to be a valid XML Name, and throw otherwise.

However, the HTML parser is less restrictive in attribute names, allowing HTML documents to have some attribute names that are illegal in XML.

Whenever it is needed to programmatically create an attribute with a name that is allowed in HTML but illegal in XML, this is possible through the parser, but not with DOM attribute creating methods, it seems.

document.createAttribute('impo$$ible'); // throws

const createHTMLAttribute = name =>
  document.importNode(
    new DOMParser().parseFromString(`<html ${name}>`, 'text/html')
      .documentElement.getAttributeNode(name)
  );

createHTMLAttribute('impo$$ible'); // 'impo$$ible=""'

Could createAttribute (and maybe setAttribute and friends) be somehow allowed to create such attributes in HTML documents?

@domenic
Copy link
Member

domenic commented Jun 26, 2019

A stalled attempt to address this is in #449.

@annevk annevk added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest labels Jun 26, 2019
@ExE-Boss
Copy link

ExE-Boss commented Dec 4, 2019

I think we should also allow this for XML5.

Assuming anyone ever implements it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest
Development

Successfully merging a pull request may close this issue.

4 participants