Re: Custom elements ES6/ES5 syntax compromise, was: document.register and ES6

Ok, I'll take your word that we get basically 1:1 and devs won't need to
recode or do any catch-casing inside constructors or protos for non-native
document.register polyfill use.

Regardless, if we are going to keep the property bag, which provides way
more than just the prototype property, it seems to me that...

document.register('x-super-button', {
    constructor: SuperButton,
    lifecycle: { ... }
});

...would still be the most concise, ergonomic syntax. Truth is, devs like
property bags. Major JS frameworks commonly use the property object pattern
for the description of new components and modules. Additionally, retaining
the property bag provides freedom to add other registration-centric
options/features at a later date - unlike 20/20 localName check hindsight,
we can *start* by retaining this flexibility now, so that hindsight does
not become not 20/13 ;)

Daniel J. Buchner
Product Manager, Developer Ecosystem
Mozilla Corporation


On Thu, Feb 14, 2013 at 2:41 PM, Erik Arvidsson <arv@chromium.org> wrote:

>
> On Thu, Feb 14, 2013 at 5:40 PM, Scott Miles <sjmiles@google.com> wrote:
>
>> In all constructions the *actual* calling of HTMLButtonElement is done by
>> the browser.
>>
>> All the user has to do is *not* call it, and only call super constructors
>> if they are custom.
>>
>> For that reason, I don't see why this is an issue.
>>
>
> Or if you want you can polyfill HTMLButtonElement.call.
>
> HTMLButtonElement.call = function() {};
>
> On Thu, Feb 14, 2013 at 2:36 PM, Daniel Buchner <daniel@mozilla.com>wrote:
>>
>>> It seems to me (please correct me if this is inaccurate) that you can't
>>> *really* polyfill ES6 extension of existing element constructor
>>> inheritance, because afaik, you cannot call the existing native
>>> constructors of elements - it throws. So if you can only do a jankified 1/2
>>> fill, why not just provide an optional route that has no legacy issues for
>>> people who want to use it?
>>>
>>> I believe even Scott's polyfill doesn't do anything to enable
>>> HTMLButtonElement.call(this);
>>>
>>> Hopefully I'm in the ballpark here, but if what I said is wrong or not
>>> an issue, what *is* the reasoning behind it?
>>>
>>> Daniel J. Buchner
>>> Product Manager, Developer Ecosystem
>>> Mozilla Corporation
>>>
>>>
>>> On Thu, Feb 14, 2013 at 2:23 PM, Scott Miles <sjmiles@google.com> wrote:
>>>
>>>> MyButton = document.register(‘x-button’, {
>>>>   prototype: MyButton.prototype,
>>>>   lifecycle: {
>>>>      created: MyButton
>>>>   }
>>>> });
>>>>
>>>> What's the benefit of allowing this syntax? I don't immediately see why
>>>> you couldn't just do it the other way.
>>>>
>>>>
>>>> On Thu, Feb 14, 2013 at 2:21 PM, Rick Waldron <waldron.rick@gmail.com>wrote:
>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Thu, Feb 14, 2013 at 5:15 PM, Erik Arvidsson <arv@chromium.org>wrote:
>>>>>
>>>>>> Yeah, this post does not really talk about syntax. It comes after a
>>>>>> discussion how we could use ES6 class syntax.
>>>>>>
>>>>>> The ES6 classes have the same semantics as provided in this thread
>>>>>> using ES5.
>>>>>>
>>>>>> On Thu, Feb 14, 2013 at 5:10 PM, Rick Waldron <waldron.rick@gmail.com
>>>>>> > wrote:
>>>>>>
>>>>>>>
>>>>>>> On Thu, Feb 14, 2013 at 4:48 PM, Dimitri Glazkov <
>>>>>>> dglazkov@google.com> wrote:
>>>>>>>
>>>>>>>>
>>>>>>>> MyButton = document.register(‘x-button’, {
>>>>>>>>   prototype: MyButton.prototype,
>>>>>>>>   lifecycle: {
>>>>>>>>      created: MyButton
>>>>>>>>   }
>>>>>>>> });
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Does this actually mean that the second argument has a property
>>>>>>> called "prototype" that itself has a special meaning?
>>>>>>>
>>>>>>
>>>>>> This is just a dictionary.
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> Is the re-assignment MyButton intentional? I see the original
>>>>>>> "MyButton" reference as the value of the created property, but then
>>>>>>> document.register's return value is assigned to the same identifier? Maybe
>>>>>>> this was a typo?
>>>>>>>
>>>>>>>>
>>>>>>>> document.register(‘x-button’, {
>>>>>>>>  constructor: MyButton,
>>>>>>>>  ...
>>>>>>>> });
>>>>>>>>
>>>>>>>>
>>>>>>> Same question as above, but re: "constructor"?
>>>>>>>
>>>>>>>
>>>>>> Same answer here.
>>>>>>
>>>>>> I'm not happy with these names but I can't think of anything better.
>>>>>>
>>>>>
>>>>> Fair enough, I trust your judgement here. Thanks for the follow
>>>>> up—always appreciated.
>>>>>
>>>>> Rick
>>>>>
>>>>>>
>>>>>> --
>>>>>> erik
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
>
> --
> erik
>
>
>

Received on Thursday, 14 February 2013 22:54:11 UTC