W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2013

Re: document.register and ES6

From: Erik Arvidsson <arv@chromium.org>
Date: Wed, 6 Feb 2013 12:03:16 -0500
Message-ID: <CAJ8+GogK3cJXq1YYAJds9Ch=rkt5Bhky7op65R4cyeDpPNjDDA@mail.gmail.com>
To: Daniel Buchner <daniel@mozilla.com>
Cc: public-webapps <public-webapps@w3.org>, Dimitri Glazkov <dglazkov@google.com>, Boris Zbarsky <bzbarsky@mit.edu>
On Tue, Feb 5, 2013 at 8:26 PM, Daniel Buchner <daniel@mozilla.com> wrote:
> I have two questions:
> Does this affect our ability to polyfill doc.register in current browsers?

Good point. This is really important to us as well so we most likely
need to tweak this to make sure it will work.

Do we need to be able to do "new MyButton" or is
document.createElement/innerHTML/parser sufficient? If we need to be
able to do "new" in the polyfill I think we either need to tweak
document.register or get the developer to cooperate (by writing
different code). At this point I don't see how we can tweak the API
and still fulfill all of the requirements.

> Are you saying we're going to nix the ability to easily register insertion,
> removal, and attribute change callbacks from the API?

No. I don't think there is any change here. Instead of passing in
functions to document.register we can call methods on the custom
element. For example:

class MyButton extends HTMLButtonElement {
  constructor() {
  handleAttributeChange(name, value) { ... }
  moreInit() { ... }
document.register('my-button', MyButton);

instead of

var myButtonPrototype = Object.create(HTMLButtonElement.prototype, {
  handleAttributeChange: {
    value: function(name, value) { ... },
    enumerable: true,
    configurable: true,
    writable: true
  moreInit: {
    value: function() { ... },
    enumerable: true,
    configurable: true,
    writable: true

var MyButton = document.register('my-button', {
  prototype:" myButtonPrototype,
  created: function(element) {
  attributeChange: function(element, name, value) {
    element.handleAttibuteChange(name, value);

Received on Wednesday, 6 February 2013 17:04:04 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:13:58 UTC