mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Serialize before deserialize when configuring attrs. Fixes #3433.
This commit is contained in:
parent
25d4f224d4
commit
ec855827fe
@ -193,7 +193,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
break;
|
||||
|
||||
case Boolean:
|
||||
value = (value !== null);
|
||||
value = (value != null);
|
||||
break;
|
||||
|
||||
case Object:
|
||||
|
@ -153,7 +153,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
var value = (p === x.effect.value) ? config[p] :
|
||||
this._get(x.effect.value, config);
|
||||
if (x.effect.kind == 'attribute') {
|
||||
value = node.deserialize(value,
|
||||
value = node.deserialize(node.serialize(value),
|
||||
node._propertyInfo[name].type);
|
||||
}
|
||||
node._configValue(name, value);
|
||||
|
@ -128,12 +128,18 @@
|
||||
type: Number,
|
||||
observer: 'attrNumberChanged',
|
||||
value: 0
|
||||
},
|
||||
attrBoolean: {
|
||||
type: Boolean,
|
||||
observer: 'attrBooleanChanged',
|
||||
// value: true
|
||||
}
|
||||
},
|
||||
|
||||
created: function() {
|
||||
this.attrDashChanged = sinon.spy();
|
||||
this.attrNumberChanged = sinon.spy();
|
||||
this.attrBooleanChanged = sinon.spy();
|
||||
}
|
||||
|
||||
});
|
||||
@ -142,7 +148,7 @@
|
||||
|
||||
<dom-module id="x-configure-host">
|
||||
<template>
|
||||
<x-configure-child id="child" content="{{content}}" object="{{object.goo}}" attr$="{{attrValue}}" attr-dash$="{{attrValue}}" attr-number$="{{attrNumber}}"></x-configure-child>
|
||||
<x-configure-child id="child" content="{{content}}" object="{{object.goo}}" attr$="{{attrValue}}" attr-dash$="{{attrValue}}" attr-number$="{{attrNumber}}" attr-boolean$="{{attrBoolean}}"></x-configure-child>
|
||||
</template>
|
||||
<script>
|
||||
Polymer({
|
||||
@ -175,7 +181,10 @@
|
||||
value: 'attrValue'
|
||||
},
|
||||
attrNumber: {
|
||||
value: '42'
|
||||
value: 42
|
||||
},
|
||||
attrBoolean: {
|
||||
value: false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
assert.notProperty(e.$.child, 'attr-number');
|
||||
assert.strictEqual(e.$.child.attrNumber, 42);
|
||||
assert.isTrue(e.$.child.attrNumberChanged.calledOnce);
|
||||
assert.equal(e.$.child.attrNumberChanged.getCall(0).args[0], 42);
|
||||
assert.strictEqual(e.$.child.attrNumberChanged.getCall(0).args[0], 42);
|
||||
|
||||
assert.equal(e.$.child.hasAttribute('attr-boolean'), false);
|
||||
assert.notProperty(e.$.child, 'attr-boolean');
|
||||
assert.strictEqual(e.$.child.attrBoolean, false);
|
||||
assert.isTrue(e.$.child.attrBooleanChanged.calledOnce);
|
||||
assert.strictEqual(e.$.child.attrBooleanChanged.getCall(0).args[0], false);
|
||||
});
|
||||
|
||||
test('pre-register property assignment does not break getters and setters', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user