mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Ensure parent node exists when stamping. Fixes #2685.
This commit is contained in:
parent
951031fccd
commit
62f2d2a298
@ -116,12 +116,16 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
_ensureInstance: function() {
|
||||
if (!this._instance) {
|
||||
// TODO(sorvell): pickup stamping logic from x-repeat
|
||||
this._instance = this.stamp();
|
||||
var root = this._instance.root;
|
||||
// TODO(sorvell): this incantation needs to be simpler.
|
||||
var parent = Polymer.dom(Polymer.dom(this).parentNode);
|
||||
parent.insertBefore(root, this);
|
||||
var parentNode = Polymer.dom(this).parentNode;
|
||||
// Guard against element being detached while render was queued
|
||||
if (parentNode) {
|
||||
var parent = Polymer.dom(parentNode);
|
||||
// TODO(sorvell): pickup stamping logic from x-repeat
|
||||
this._instance = this.stamp();
|
||||
var root = this._instance.root;
|
||||
// TODO(sorvell): this incantation needs to be simpler.
|
||||
parent.insertBefore(root, this);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -56,6 +56,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<template id="trueif">
|
||||
<template is="dom-if" if>
|
||||
<div></div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
suite('nested pre-configured dom-if', function() {
|
||||
@ -493,6 +499,21 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
});
|
||||
|
||||
suite('queueing race conditions', function() {
|
||||
|
||||
test('domif=true, attach, detach', function(done) {
|
||||
var domif = document.importNode(document.querySelector('#trueif').content, true).firstElementChild;
|
||||
document.body.appendChild(domif);
|
||||
document.body.removeChild(domif);
|
||||
setTimeout(function() {
|
||||
document.body.appendChild(domif);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user