[Bug 20913] [Custom]: Meaning of prototype in document.register is underspecified

https://www.w3.org/Bugs/Public/show_bug.cgi?id=20913

--- Comment #15 from Daniel Buchner <danieljb2@gmail.com> ---
In the following feedback, I'll highlight what I see as the most
developer-friendly, ergonomic combination of the various concerns before us. In
response, I would like to know what the major blockers or concerns are in
relation to feasibility. (Some of the points below are already know or have
been detailed in previous comments - they are included for cohesion)

1. Developers should be able to subclass elements with ES6 methods, but
sub-classing should not implicitly register them with the parser.

 - document.register and class extension should not be - and need not be -
synonymous. These interfaces represent two different conceptual functions: 1)
creating new objects that inherit from a previously declared
HTMLElement-objects, and 2) registering an element prototype for parser and DOM
method functionality.

 - ES6 extension of elements need not affect document.register if the register
method understands that the second property could be an options object, or an
HTMLElement-inheriting object.

2. Developers should have access to all properties that existed on the base
prototype whether declaring elements via tag or attribute. This means that
setting 'src' on an <x-loader>, that was derived from { prototype:
Object.create() } using HTMLScriptElement as a proto base should work - if it
doesn't, that is non-optimal and should be corrected (feasible? Not sure. I'll
plead ignorance on this point and defer to you all)

Examples to illustrate the above points:

This should work:

class SuperScript extends HTMLScriptElement;
document.register('super-script', SuperScript);

So should this:

document.register('super-script', {
    prototype: Object.create(HTMLScriptElement.prototype, { ... })
});

*** Recommendation ***

Do not return constructors from document.register, ever.

We should leave user-facing constructor generation to ES6 and make
document.register understand them when used as the second parameter.

In talking to just about every developer friend I could get a hold of over the
weekend I found that...no one cares about constructors. Maybe that changes in 4
years when most browsers have ES6 implemented. They told me they can't use the
constructors of 99.5% of elements currently, so they could care less as long as
document.createElement('super-script') works.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Monday, 11 February 2013 23:29:03 UTC