-
Notifications
You must be signed in to change notification settings - Fork 396
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
Wrong syntax for document.createElement() options #3335
Comments
Interestingly, puppeteer fails the existing test when using All that goes to say that when travis finishes doing its thing, the change will be on edge, and we'll see where it goes from there. I imagine there's probably a better way to use custom elements now, maybe just by throwing them in a tag, and it would probably be best to support that. I haven't personally used any though, as I haven't felt the need, so if anyone has any guidance, it would be appreciated. |
Here's a quick and dirty example to test a custom element that extends a native element: customElements.define('div-with-span',
class extends HTMLDivElement {
constructor() {
super();
this.innerHTML = '<span>testing 3 2 1</span>';
}
}, {extends: 'div'});
document.body.append(document.createElement('div', {is: 'div-with-span'})); Is that what you were looking for? Is there anything else I can help with? Thanks! |
BTW, Puppeteer OK if you use |
I did successfully test the behavior like you suggested, but I can't create a test case due to the way the code is transpiled. That transpilation also handles converting I was wondering if there are more ergonomic uses of custom elements, like |
You can just check to make sure the new element is an class DivWithSpan extends HTMLDivElement {
constructor() {
super();
this.innerHTML = '<span>testing 3 2 1</span>';
}
}
customElements.define('div-with-span', DivWithSpan, {extends: 'div'});
const mydiv = document.createElement('div', {is: 'div-with-span'});
console.assert(mydiv instanceof DivWithSpan); |
The three uses of
extend
, starting on this line are passing theextend
value directly todocument.createElement()
anddocument.createElementNS()
, but the caller is passing inthis.getAttribute('is')
, which is just a string so can't be used directly but instead needs to be wrapped in a{is: ...}
, see the descriptions of theoptions
parameter in MDN's docs.Here's my recommended diff:
The text was updated successfully, but these errors were encountered: