[webcomponents] Binding Custom Element without Polluting Global Scope (Was Proposal for Cross Origin Use Case and Declarative Syntax)

On Nov 12, 2013, at 12:45 AM, Ryosuke Niwa <rniwa@apple.com> wrote:
> On Nov 12, 2013, at 8:12 AM, Dimitri Glazkov <dglazkov@chromium.org> wrote:
>> 1) It is not friendly to ES6 classes. In fact, you can't use class syntax and this syntax together.

Okay, let the author define the constructor.

>> 3) The approach pollutes global name space with constructors. This had been voiced many times as unacceptable by developers.

We can solve this problem by using JavaScript "object path" as opposed to a variable name.

So instead of:
<template register="my-button" interface="MyButton">
</template>

We allow:
<script>
var my = {views:{MyButton: ~}};
</script>
<template register="my-button" interface="my.views.MyButton">
</template>

While this requires some variable to be exposed on the global scope, libraries and frameworks do this already, and authors could use document.register to avoid that altogether if they really wanted.

- R. Niwa

Received on Friday, 6 December 2013 03:25:24 UTC