Re: Web Component Element definition

> ({
>   readyCallback: function() { },
>   get foo() {},
>   set foo() {}
> })
> confuses me... I 've seen the whole
> ({
> })
> construct in web comps for the first time and I think it's web comps
> specific...
>

This is normal, if somewhat obscure, JavaScript.


> and the setters and getters... from your example... are those getter and
> setters for method foo or property foo? Shouldn't setter have a parameter?
> The value that is about to be set? how do I define whether property is
> changable, enumerable?
>

These are JavaScript questions and have nothing to do with web components
spec.

There is only one type of getter/setter. The get/set I showed is just an
alternate syntax for the more verbose (and powerful) descriptor syntax.
Yes, setter takes a parameter. If you want to alter property flags
(enumerable) then use descriptors.

The following are essentially equivalent:

p = {
  get property() { return 5; },
  set property(value) {}
};

with descriptors:

p = Object.create(Object.prototype, {
  property: {
    get: function() { return 5; },
    set: function(value) {}
  }
});

S

Received on Sunday, 23 June 2013 19:58:07 UTC