Re: [w3c/webcomponents] The is="" attribute is confusing? Maybe we should encourage only ES6 class-based extension. (#509)

@trusktr 
> For things like
>  ```html
><table>
>    <my-tr>
> ```
> Can you just use CSS to style my-tr elements the same as the browser's default styling for tr elements?

I cannot as (at least the old browsers) will put `<my-tr>` outside of `<table>` and we cannot just break backward compatibility, like that.

>  Browsers should be cleaned up, and anything that extends from HTMLTemplateElement should behave as a <template> element does. Anything that extends from HTMLTableRowElement should behave as such

I do agree that conceptually, that is nice and clean. Once we extend it with `class MyTr extends HTMLTableRowElement` we should be able to use it as just `<my-tr>`. However, even if we would get all the a11y, parsing, styling, serializing behavior, and disregard PE for a moment, by limiting ourselves to just this syntax we will loose readability from HTML perspective. The new-comer will have to read (minified) JS source to figure about whether `<my-element>` behaves more-or-less like `<tr>`, `<tbody>` or `<caption>`.

Even though I'm not a browser implementer, I would expect that changing parser behavior in run-time would be extremely expensive.

The solution with 
```
 c.innerHTML = c.innerHTML.replace('<table', '<my-table').replace('<tr', '<my-tr')
```
Would trigger a lot of unnecessary DOM mutations, re-paints, FOUC, etc. 

I wouldn't say `<my-table><my-tr>` is a solution, as just to deliver custom `<tr>` I would have to re-implement `<table>`, `<thead>`, `<tbody>`, etc. and what is even worse, force my user (developer who consumes my CE) to use those. Instead, for example `<trusktr-thead>` which could be awesome and needed as well. So we are loosing composability, which is in my opinion key feature of CE and HTML in general.

BTW, I do agree that sticking to polyfill of just `is=""` until V2 will somehow address this problem is a way to go and that's the way we "moved the Web forward" for recent years. Especially [that's the price for getting the rest of V1 sooner](https://github.com/w3c/webcomponents/issues/509#issuecomment-266174073).
I just want to state, that there are use-cases which are not covered w/o `is`. Plus, polyfill which covers it in 100% is not trivial (if even possible).
That's why, I would really love to hope, that someday the solution would be in the signed spec.

I also feel the pain explaining the change from V0 to V1 instead just advertising a new feature/spec. But, I feel there is a significant group of developers who already rely on `is`  since V0, so we are already here.

-- 
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/509#issuecomment-266431248

Received on Monday, 12 December 2016 17:45:13 UTC