WICG / layout-instability

A proposal for a Layout Instability specification
https://wicg.github.io/layout-instability/
Other
159 stars 27 forks source link

Attributes cannot accept sequence types - 'sources' #40

Closed stephenmcgruer closed 4 years ago

stephenmcgruer commented 4 years ago

The recent change to add LayoutShiftAttribution was just imported into WPT in https://github.com/web-platform-tests/wpt/pull/22499

The automatic idlharness file appears to have caught an error:

FAIL message: promise_test: Unhandled rejection with value: object "WebIDLParseError: Syntax error at line 11 in layout-instability, since `interface LayoutShift`:
 attribute sequence<LayoutShiftAttribution> sources;
                                            ^ Attributes cannot accept sequence types"

https://wpt.fyi/results/layout-instability/idlharness.window.html?diff&filter=ADC&run_id=441160005&run_id=460560003

npm1 commented 4 years ago

Oh right... We probably want to have a method getSources then.

skobes-chromium commented 4 years ago

Why can't attributes be sequences?

stephenmcgruer commented 4 years ago

From https://heycam.github.io/webidl/#sequence-type:

Sequences must not be used as the type of an attribute or constant.

Note: This restriction exists so that it is clear to specification writers and API users that sequences are copied rather than having references to them passed around. Instead of a writable attribute of a sequence type, it is suggested that a pair of operations to get and set the sequence is used.

skobes-chromium commented 4 years ago

Hmm, we don't need pass-by-value. Is there a better way to declare an array-like property of an object?

skobes-chromium commented 4 years ago

I am tempted to return to FrozenArray, though npm had concerns about that...

npm1 commented 4 years ago

Ok, let's try FrozenArray for now. My concern is that it says the it has a fixed length array of unmodifiable values. From what I understand your list is fixed length but modifiable. That can be a question for the TAG too :)