- From: Andrea Giammarchi <notifications@github.com>
- Date: Mon, 21 Sep 2015 14:33:47 -0700
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Message-ID: <w3c/webcomponents/issues/326/142115167@github.com>
I've been told to CC @annevk , @rniwa , @hayatoito , and @travisleithead about this, so here i am.
The long discussion about `is` property and the `extends` one is that "anyone could wrap an input, a select, a form ... " etc, etc ...
When it comes to partial applications, the element cannot be just inherited, and `is` behavior, as well as `extends` is the only way to resolve the issue.
### Example
In a partial application we might want to create a `CustomElement` that should act lake a `HTMLTableRowElement`
```js
var MyTr = document.registerElement('my-tr', {prototype: Object.create(HTMLTableRowElement.prototype)});
var mtr = new MyTr;
mtr.innerHTML = '<td>1</td><td>2</td>';
mtr.innerHTML // "12" <== SEE THAT? EPIC FAIL
```
If the component just inherits `HTMLTableRowElement.prototype` it can be used to be appended to a generic `tbody` but it won't preserve its content as html.
Only using the good old way works:
```js
var mtr = document.createElement('tr');
mtr.innerHTML = '<td>1</td><td>2</td>';
mtr.innerHTML // "<td>1</td><td>2</td>" <== OK
```
Partial rows, cells, cols or any other table related application can be very useful.
As example, [this replication of the (in)famous DBMonster benchmark](https://github.com/WebReflection/dom-class/blob/master/demo/db-monster.js) uses 3 components:
* the `HTMLTableElement` one to create a table component
* the `HTMLTableRowElement` one to create [each row](https://github.com/WebReflection/dom-class/blob/master/demo/db-monster.js#L86) of such table
* the `HTMLTableCellElement` to create [last 5 cells](https://github.com/WebReflection/dom-class/blob/master/demo/db-monster.js#L33) of each rows
The [benchmark page](https://github.com/WebReflection/dom-class/blob/master/demo/dbmonster.html) as it is [works like a charm](http://webreflection.github.io/dom-class/demo/dbmonster.html) in every [polyfilled](https://github.com/WebReflection/document-register-element) platform but it would be impossible to recreate such simple use case (even if stressed in this bench) without the usage of the `is` specification.
---
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/326#issuecomment-142115167
Received on Monday, 21 September 2015 21:34:14 UTC