Skip to content

Commit 957c8c4

Browse files
author
Steven Orvell
committed
Address review feedback.
1 parent f8dfaa5 commit 957c8c4

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

externs/webcomponents-externs.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,8 @@ HTMLTemplateElement.decorate = function(template){};
6666
* @param {function(function())} cb callback
6767
*/
6868
CustomElementRegistry.prototype.polyfillWrapFlushCallback = function(cb){};
69+
70+
/**
71+
* @param {string} cssText
72+
*/
73+
CSSStyleSheet.prototype.replaceSync = function(cssText) {};

lib/legacy/class.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ function GenerateClassFromInfo(info, Base, behaviors) {
291291
const a = this.attributes;
292292
for (let i=0, l=a.length; i < l; i++) {
293293
const attr = a[i];
294-
this.__attributeReaction(attr.name, undefined, attr.value);
294+
this.__attributeReaction(attr.name, null, attr.value);
295295
}
296296
}
297297
super.created();
@@ -309,6 +309,7 @@ function GenerateClassFromInfo(info, Base, behaviors) {
309309
}
310310
}
311311

312+
/** @override */
312313
setAttribute(name, value) {
313314
if (legacyNoObservedAttributes) {
314315
const oldValue = this.getAttribute(name);
@@ -319,6 +320,7 @@ function GenerateClassFromInfo(info, Base, behaviors) {
319320
}
320321
}
321322

323+
/** @override */
322324
removeAttribute(name) {
323325
if (legacyNoObservedAttributes) {
324326
const oldValue = this.getAttribute(name);
@@ -472,6 +474,7 @@ function GenerateClassFromInfo(info, Base, behaviors) {
472474
}
473475

474476
// NOTE: Inlined for perf from version of DisableUpgradeMixin.
477+
/** @override */
475478
static get observedAttributes() {
476479
return legacyNoObservedAttributes ? [] :
477480
observedAttributesGetter.call(this).concat(DISABLED_ATTR);

test/unit/legacy-noattributes.html

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,23 @@
6464
shouldIf: Boolean,
6565
camelCase: String,
6666
disabled: {type: Boolean, value: 'true'}
67+
},
68+
attributeChanged(name, old, value) {
69+
this.attrInfo = {name, old, value};
6770
}
6871
});
6972
</script>
7073
</dom-module>
7174

7275
<test-fixture id="declarative">
7376
<template>
74-
<x-attrs id="configured" foo="foo" bar="bar" camel-case="camelCase"></x-attrs>
77+
<x-attrs foo="foo" bar="bar" camel-case="camelCase"></x-attrs>
78+
</template>
79+
</test-fixture>
80+
81+
<test-fixture id="one-attr">
82+
<template>
83+
<x-attrs foo="foo"></x-attrs>
7584
</template>
7685
</test-fixture>
7786

@@ -94,6 +103,21 @@
94103
assert.equal(el.camelCase, 'camelCase');
95104
});
96105

106+
test('attributeChanged gets expected arguments', () => {
107+
el = fixture('one-attr');
108+
assert.deepEqual(el.attrInfo, {name: 'foo', old: null, value: 'foo'});
109+
el.setAttribute('zot', '');
110+
assert.deepEqual(el.attrInfo, {name: 'zot', old: null, value: ''});
111+
el.setAttribute('zot', 'foo');
112+
assert.deepEqual(el.attrInfo, {name: 'zot', old: '', value: 'foo'});
113+
el.removeAttribute('zot', 'foo');
114+
assert.deepEqual(el.attrInfo, {name: 'zot', old: 'foo', value: null});
115+
el.setAttribute('zot', 'bar');
116+
assert.deepEqual(el.attrInfo, {name: 'zot', old: null, value: 'bar'});
117+
el.setAttribute('foo', 'foo2');
118+
assert.deepEqual(el.attrInfo, {name: 'foo', old: 'foo', value: 'foo2'});
119+
})
120+
97121
test('static attribute bindings', () => {
98122
assert.equal(el.$.child1.getAttribute('bar'), 'bar');
99123
assert.equal(el.$.child1.bar, 'bar');

0 commit comments

Comments
 (0)