Is it allowed to use any type for a @published attribute in a polymer element?

StackOverflow https://stackoverflow.com/questions/22606113

  •  20-06-2023
  •  | 
  •  

문제

I have a custom polymer element like this :

@CustomTag('my-game')
class GameElement extends PolymerElement {
  @published GameState state;

  // .....
}

And I use it like this :

<my-game state="{{ state }}" />

As the attributes property on Element is a Map<String, String> is it allowed to use any type for @published attributes?

도움이 되었습니까?

해결책

Yes this works.
I use this to assign my model classes from parent to child elements.

Do you have any issues with it?

An issue with this is, that the DOM doesn't see the attribute being added.
In an unit test I tried to use a MutationObserver to be notified when an attribut was set,
but this works only when a primitive value is assigned.

see https://code.google.com/p/dart/issues/detail?id=17472

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top