|
85 | 85 | xfoo.foo = 5;
|
86 | 86 | xfoo.setAttribute('def1', '15');
|
87 | 87 | xfoo.def2 = 15;
|
88 |
| - Platform.flush(); |
| 88 | + // |
89 | 89 | assert.isFalse(xcompose.$.bar.hasAttribute('zim'), 'attribute bound to property updates when binding is made');
|
90 | 90 | assert.equal(xfoo.getAttribute('def2'), '15', 'default valued published property reflects to attr');
|
91 | 91 | assert.equal(xfoo.def1, '15', 'attr updates default valued published property');
|
|
94 | 94 | assert.equal(xfoo.foo, xfoo.getAttribute('foo'), 'property reflects attribute');
|
95 | 95 | //
|
96 | 96 | xfoo.baz = 'Hello';
|
97 |
| - Platform.flush(); |
| 97 | + // |
98 | 98 | assert.equal(xfoo.baz, xfoo.getAttribute('baz'), 'attribute reflects property');
|
99 | 99 | //
|
100 | 100 | var xbar = document.querySelector('x-bar');
|
|
104 | 104 | xbar.zim = true;
|
105 | 105 | xbar.str = 'str!';
|
106 | 106 | xbar.obj = {hello: 'world'};
|
107 |
| - Platform.flush(); |
| 107 | + // |
108 | 108 | assert.equal(xbar.foo, xbar.getAttribute('foo'), 'inherited published property is reflected');
|
109 | 109 | assert.equal(String(xbar.zot), xbar.getAttribute('zot'), 'attribute reflects property as number');
|
110 | 110 | assert.equal(xbar.getAttribute('zim'), '', 'attribute reflects true valued boolean property as having attribute');
|
111 | 111 | assert.equal(xbar.str, xbar.getAttribute('str'), 'attribute reflects property as published string');
|
112 | 112 | assert.isFalse(xbar.hasAttribute('obj'), 'attribute does not reflect object property');
|
| 113 | + // |
113 | 114 | xbar.setAttribute('zim', 'false');
|
114 | 115 | xbar.setAttribute('foo', 'foo!!');
|
115 | 116 | xbar.setAttribute('zot', 54);
|
116 | 117 | xbar.setAttribute('str', 'str!!');
|
117 | 118 | xbar.setAttribute('obj', "{'hello': 'world'}");
|
| 119 | + // |
118 | 120 | assert.equal(xbar.foo, xbar.getAttribute('foo'), 'property reflects attribute as string');
|
119 | 121 | assert.equal(xbar.zot, 54, 'property reflects attribute as number');
|
120 | 122 | assert.equal(xbar.zim, false, 'property reflects attribute as boolean');
|
121 | 123 | assert.equal(xbar.str, 'str!!', 'property reflects attribute as published string');
|
122 | 124 | assert.deepEqual(xbar.obj, {hello: 'world'}, 'property reflects attribute as object');
|
| 125 | + // |
123 | 126 | xbar.zim = false;
|
124 |
| - Platform.flush(); |
| 127 | + // |
125 | 128 | assert.isFalse(xbar.hasAttribute('zim'), 'attribute reflects false valued boolean property as NOT having attribute');
|
| 129 | + // |
126 | 130 | var objAttr = xbar.getAttribute('obj');
|
127 | 131 | oneMutation(xbar, {attributes: true}, function() {
|
128 | 132 | assert.equal(xbar.getAttribute('obj'), 'hi', 'reflect property based on current type');
|
129 | 133 | //assert.isFalse(xbar.hasAttribute('obj'), 'property with default type of object does not serialize');
|
130 | 134 | done();
|
131 | 135 | });
|
132 |
| - |
| 136 | + // |
133 | 137 | var xzot = document.querySelector('x-zot');
|
134 | 138 | assert.equal(xzot.str, 'str2');
|
135 | 139 | xzot.str = 'hello';
|
136 | 140 | assert.equal(xzot.getAttribute('str'), xzot.str);
|
137 |
| - |
| 141 | + // |
138 | 142 | assert.equal(xzot.zot, 2);
|
139 | 143 | xzot.zot = 5;
|
140 | 144 | assert.isFalse(xzot.hasAttribute('zot'), 'extendee reflect false not honored');
|
141 |
| - |
| 145 | + // |
142 | 146 | xbar.obj = 'hi';
|
143 |
| - Platform.flush(); |
144 | 147 | // trigger a mutation to watch
|
145 | 148 | xbar.setAttribute('dummy', 'dummy');
|
| 149 | + // |
| 150 | + // don't let observe polyfill wait, flush asap |
| 151 | + Platform.flush(); |
146 | 152 | });
|
147 | 153 | </script>
|
148 | 154 | </body>
|
|
0 commit comments