mirror of
https://github.com/konvajs/konva.git
synced 2026-01-23 05:14:58 +08:00
Fixed set container for dangling stage, related to #510
This commit is contained in:
@@ -190,7 +190,9 @@ export class Stage extends Container<BaseLayer> {
|
|||||||
}
|
}
|
||||||
this._setAttr(CONTAINER, container);
|
this._setAttr(CONTAINER, container);
|
||||||
if (this.content) {
|
if (this.content) {
|
||||||
this.content.parentElement.removeChild(this.content);
|
if (this.content.parentElement) {
|
||||||
|
this.content.parentElement.removeChild(this.content);
|
||||||
|
}
|
||||||
container.appendChild(this.content);
|
container.appendChild(this.content);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -203,6 +203,18 @@ suite('Stage', function() {
|
|||||||
assert.equal(clone.content, container.children[0]);
|
assert.equal(clone.content, container.children[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('dangling stage ', function() {
|
||||||
|
var stage = addStage();
|
||||||
|
var container = stage.container();
|
||||||
|
var parent = stage.content.parentElement
|
||||||
|
|
||||||
|
parent.removeChild(stage.content);
|
||||||
|
|
||||||
|
stage.setContainer(container);
|
||||||
|
|
||||||
|
assert.equal(stage.container(), container);
|
||||||
|
})
|
||||||
|
|
||||||
// ======================================================
|
// ======================================================
|
||||||
test('stage getIntersection()', function() {
|
test('stage getIntersection()', function() {
|
||||||
var stage = addStage();
|
var stage = addStage();
|
||||||
|
|||||||
Reference in New Issue
Block a user