[Bug 20831] New: [Custom]: Make document.register work with ES6 classes and @@create

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

            Bug ID: 20831
           Summary: [Custom]: Make document.register work with ES6 classes
                    and @@create
    Classification: Unclassified
           Product: WebAppsWG
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Component Model
          Assignee: dglazkov@chromium.org
          Reporter: arv@chromium.org
        QA Contact: public-webapps-bugzilla@w3.org
            Blocks: 14968

http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts

We need to make document.register work with ES6 classes and the ES6 @@create
hook. For example:

class MyButton extends HTMLButton {
  constructor(text) {
    super();
    this.textContent = text;
  }
}
document.register('my-button', {
  class: MyButton
});

Here is a rough draft/idea of how we need to modify the spec:

Modify the algorithm at
https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/index.html#dfn-document-register.
This is a bit hand wavy and it ignores fallback on using "prototype".

1. If NAME is an invalid custom element name, throw an InvalidCharacterError
exception.
2. If CLASS is not a Function throw TypeError.
3. Let PROTOTYPE be [[Get]](CLASS, "prototype").
4. If PROTOTYPE does not have Element.prototype on its prototype chain, throw a
TypeError exception.
...
9?. Define CLASS.@create to be a function that creates a new element with the
NAME as the tag name. TODO: Namespace from the prototype?
10. Return CLASS (for convenience?).

The create function in 9? is defined by
https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/index.html#dfn-custom-element-instantiation

I don't think we do not need the element finalization at all here since the
constructor is itself the element finalization.

Since ES6 classes are just pure syntactic sugar for ES5 we should be able to
the same thing for ES5. The new thing in ES6 is the @@create hook. For ES5 we
could return an alternative function in step 10 that creates the instance
object and then calls the user provided function.

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

Received on Thursday, 31 January 2013 00:00:28 UTC