notify
and reflectToAttribute
. The notify
and reflectToAttribute
properties may sound similar: they both make the element's state visible to the outside world. reflectToAttribute
makes the state visible in the DOM tree, so that it's visible to CSS and thequerySelector
methods. notify
makes state changes observable outside the element, either using JavaScript event handlers or Polymer .
用实例演示一下两者的区别。以下代码仅适用于polymer 1.0。
icon-toggle.html
icon-toggle-demo.html
Statically-configured icon-toggles1
Data-bound icon-toggle
[[ival]][[message(isFav)]]
测试页面:
执行效果:
效果影响:
1、如果在icon-toggle中去除:reflectToAttribute: true,则点击图标时,填充效果将无效,但msg效果是有效的,即仍会在:You really like me! 和 Do you linke me?之间切换。
2、如果去除:notify: true 属性,则填充效果有效,但msg的切换效果则会消失。