W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2016

[Custom Elements] Not requiring hyphens in names.

From: /#!/JoePea <trusktr@gmail.com>
Date: Wed, 13 Apr 2016 11:12:11 -0700
Message-ID: <CAKU1PAU=pCLUwRwuXfEEe-C4UqzSLWH3b3g9fBR=-kk7+zvRdg@mail.gmail.com>
To: public-webapps@w3.org
I personally don't like this limitation. I think Custom Elements would
be better if we could create elements that have <any> <name> <that>
<we> <want>, with the possible exception that we can't override the
native elements.

Based on my previous email about registering elements on shadow roots,
I think being able to choose any name would make things just cleaner:

```js
//  --------------- SomeElement.js
import MyElement from './MyElement'

export default
class SomeElement extends HTMLElement {
    constructor() {
        this.root = this.createShadowRoot()
        this.root.registerElement('MyElement', MyElement) //
<myelement> or <MyElement>

        const frag = document.createDocumentFragment()
        frag.innerHTML = `
            <div>
              <MyElement>
                  ...
              </MyElement>
            </div>
        `
        this.root.appendChild(frag)
    }

    static get observedAttributes() { return [ ... ] }
    connectedCallback() { ... }
    disconnectedCallback() { ... }
    attributeChangedCallback() { ... }
}

//  --------------- app.js
import SomeElement from './SomeElement'

// elements registered on the document won't cross into shadow roots
document.registerElement('SomeElement', SomeElement)
document.body.appendChild(document.createElement('someelement'))
```

/#!/JoePea
Received on Wednesday, 13 April 2016 18:13:18 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:27:39 UTC