我有一个Polymer 1.0自定义元素,它具有boolean类型的属性,默认值设置为true:
myProperty: {
type: Boolean,
value: true
}
Run Code Online (Sandbox Code Playgroud)
在我的单元测试中,我将my-property设置为false来实例化这个自定义元素:
<my-custom-element id="myElem" my-property="false"></my-custom-element>
var elem = document.getElementById('myElem');
test('it_should_set_myProperty_to_false', function () {
assert.equal(elem.myProperty, false);
})
Run Code Online (Sandbox Code Playgroud)
单元测试失败了.elem.myProperty当我希望它是假的时,实际上设置为true.为什么是这样?