ibm-js / delite

HTML Custom Element / Widget infrastructure
http://ibm-js.github.io/delite/
Other
68 stars 28 forks source link

CustomElement: use comma to separate elements in array properties #484

Closed wkeese closed 7 years ago

wkeese commented 7 years ago

CustomElement supports declarative initialization of properties that are arrays of strings. However, the inline comment says to separate array elements with commas whereas the code looks for spaces.

Change the code to match the comment and old dijit behavior, i.e.:

register("my-element", [HTMLElement, CustomElement], {
     myArray: [],
});

and then:

<my-element myArray="1,2,3">

For other situations, such strings containing commas or arrays of numbers, code must use the JSON conversion on generic objects, i.e.:

register("my-fancy-element", [HTMLElement, CustomElement], {
     myObj: null,
});

and then:

<my-fancy-element myObj="[1,2,3,'string with commas ,,,']">

@cc brunano21

PS: I traced the array parsing code back to 731e67c877458f812bdcf6b17e38e43daa738823 but it's unclear if I was doing spaces instead of commas intentionally or not. The argument for spaces is that that's how CSS class works.