On Tue, May 14, 2013 at 2:04 PM, Daniel Buchner <daniel@mozilla.com> wrote:
>
> On Tue, May 14, 2013 at 1:58 PM, Erik Arvidsson <arv@chromium.org> wrote:
>
>>
>> <element name="foo-bar">
>> ...
>> <script>
>> class FooBar {
>> ...
>> };
>> </script>
>> </element>
>
>
> Is it then possible to explicitly return the class after definition? I'm
> asking because <script> return value is something I was not aware of.
>
Yes, by wrapping it in parenthesis. The spec
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-13.5 seems to say
that (class X { }) returns X but class X { } at the top level returns
undefined.
Thankfully it's not too gross, you'd just have:
<script>
(class MyCustomWidget : HTMLElement {
// ...
})
</script>
... ...
> <script>
> class FooBar {
> ...
> };
>
> return FooBar;
>
>
>
"return" isn't valid in the top level execution block which sucks. It would
nice if we relaxed that restriction and allowed a return up there.
- E