mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #3161 from Polymer/3157-kschaaf-domif-textnode
Custom setProperty for bindings to hidden textNodes. Fixes #3157.
This commit is contained in:
commit
2c6161c253
@ -124,6 +124,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
archetype._scopeElementClass = this._scopeElementClassImpl;
|
||||
archetype.listen = this._listenImpl;
|
||||
archetype._showHideChildren = this._showHideChildrenImpl;
|
||||
archetype.__setPropertyOrig = this.__setProperty;
|
||||
archetype.__setProperty = this.__setPropertyImpl;
|
||||
// boilerplate code
|
||||
var _constructor = this._constructorImpl;
|
||||
var ctor = function TemplateInstance(model, host) {
|
||||
@ -168,6 +170,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
}
|
||||
},
|
||||
|
||||
__setPropertyImpl: function(property, value, fromAbove, node) {
|
||||
if (node && node.__hideTemplateChildren__ && property == 'textContent') {
|
||||
property = '__polymerTextContent__';
|
||||
}
|
||||
this.__setPropertyOrig(property, value, fromAbove, node);
|
||||
},
|
||||
|
||||
_debounceTemplate: function(fn) {
|
||||
Polymer.dom.addDebouncer(this.debounce('_debounceTemplate', fn));
|
||||
},
|
||||
@ -242,7 +251,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
}, {
|
||||
kind: 'notify',
|
||||
fn: Polymer.Bind._notifyEffect,
|
||||
effect: {event:
|
||||
effect: {event:
|
||||
Polymer.CaseMap.camelToDashCase(parentProp) + '-changed'}
|
||||
}];
|
||||
Polymer.Bind._createAccessors(proto, parentProp, effects);
|
||||
@ -259,7 +268,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
}
|
||||
this._extendTemplate(template, proto);
|
||||
template._pathEffector = function(path, value, fromAbove) {
|
||||
return self._pathEffectorImpl(path, value, fromAbove);
|
||||
return self._pathEffectorImpl(path, value, fromAbove);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -165,13 +165,18 @@
|
||||
<div>1</div>
|
||||
<div>2</div>
|
||||
<div>3</div>
|
||||
Stuff
|
||||
{{text}}
|
||||
<div>4</div>
|
||||
</template>
|
||||
</template>
|
||||
<script>
|
||||
Polymer({
|
||||
is: 'x-textcontent'
|
||||
is: 'x-textcontent',
|
||||
properties: {
|
||||
text: {
|
||||
value: 'Stuff'
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</dom-module>
|
||||
|
@ -495,6 +495,27 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
document.body.removeChild(x);
|
||||
});
|
||||
|
||||
test('binding to text nodes changed while if=false', function() {
|
||||
var x = document.createElement('x-textcontent');
|
||||
document.body.appendChild(x);
|
||||
x.$.domIf.render();
|
||||
var stamped = Polymer.dom(x.root).childNodes;
|
||||
assert.equal(stamped.length, 12);
|
||||
assert.equal(stamped[7].textContent.trim(), 'Stuff');
|
||||
x.$.domIf.if = false;
|
||||
x.$.domIf.render();
|
||||
x.text = 'Hollaaaaa!';
|
||||
stamped = Polymer.dom(x.root).childNodes;
|
||||
assert.equal(stamped.length, 12);
|
||||
assert.equal(stamped[7].textContent.trim(), '');
|
||||
x.$.domIf.if = true;
|
||||
x.$.domIf.render();
|
||||
stamped = Polymer.dom(x.root).childNodes;
|
||||
assert.equal(stamped.length, 12);
|
||||
assert.equal(stamped[7].textContent.trim(), 'Hollaaaaa!');
|
||||
document.body.removeChild(x);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
suite('queueing race conditions', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user