Re: [w3c/webcomponents] Scoped Custom Element Registries (#716)

@trusktr Although I really like the idea of hyphen-less names what would happen if you happen to upgrade an existing name?

e.g. What on earth would happen in this situation:

```js
<link rel="stylesheet" src=".." />

<script>
    class MyLink extends HTMLElement {
        constructor() {
            // Would this still be a proper link element?

            // If so this clearly wouldn't work as HTMLLinkElement
            // doesn't support attachShadow 
            this.attachShadow({ mode: 'open' })
        }
    }

    window.customElements.define('link', MyLink)
</script>
```

Now I think this could actually be resolvable by having a special element that *must* be included in head (similar to `<base>`/`<meta>`) that declares all names that will be overridden so that the browser knows ahead of time not to assign *any* builtin behavior to those elements.

For example it might look something like this:

```html
<head>
    <override element="link">
    <override element="input">
    <!-- Or maybe <override elements="link input">
</head>
<body>
    <!-- link no longer works as a link tag but is just a plain html tag -->
    <link rel="stylesheet" />

    <!-- Neither does input -->
    <input type="date">

    <script>
        ...
        customElements.define('input', MyCustomInput)
    </script>
</body> 
```

Of course this doesn't explain what'd happen if `override` itself is overriden (not allowed? namespaces (`<html:override element="link">`)?) or any other tag like `meta`. Perhaps metadata tags would need to be strictly reserved by html (which would prevent future metadata tags being added but maybe the existing metadata tags (particularly `<meta>`) are already sufficiently flexible for all such purposes?).

I think it's simpler to keep this and #658 separate given that I don't think it's worth blocking scoped registries on a topic that I personally think is much more complicated than scoped registries.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/716#issuecomment-365153727

Received on Tuesday, 13 February 2018 05:17:23 UTC