mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
when a new stage is instantiated, it now clears the container DOM element
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
SPACE = ' ',
|
SPACE = ' ',
|
||||||
UNDERSCORE = '_',
|
UNDERSCORE = '_',
|
||||||
CONTAINER = 'container',
|
CONTAINER = 'container',
|
||||||
|
EMPTY_STRING = '',
|
||||||
EVENTS = [MOUSEDOWN, MOUSEMOVE, MOUSEUP, MOUSEOUT, TOUCHSTART, TOUCHMOVE, TOUCHEND],
|
EVENTS = [MOUSEDOWN, MOUSEMOVE, MOUSEUP, MOUSEOUT, TOUCHSTART, TOUCHMOVE, TOUCHEND],
|
||||||
|
|
||||||
// cached variables
|
// cached variables
|
||||||
@@ -554,12 +555,17 @@
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
_buildDOM: function() {
|
_buildDOM: function() {
|
||||||
|
var container = this.getContainer();
|
||||||
|
|
||||||
|
// clear content inside container
|
||||||
|
container.innerHTML = EMPTY_STRING;
|
||||||
|
|
||||||
// content
|
// content
|
||||||
this.content = document.createElement(DIV);
|
this.content = document.createElement(DIV);
|
||||||
this.content.style.position = RELATIVE;
|
this.content.style.position = RELATIVE;
|
||||||
this.content.style.display = INLINE_BLOCK;
|
this.content.style.display = INLINE_BLOCK;
|
||||||
this.content.className = KINETICJS_CONTENT;
|
this.content.className = KINETICJS_CONTENT;
|
||||||
this.attrs.container.appendChild(this.content);
|
container.appendChild(this.content);
|
||||||
|
|
||||||
this.bufferCanvas = new Kinetic.SceneCanvas();
|
this.bufferCanvas = new Kinetic.SceneCanvas();
|
||||||
this.hitCanvas = new Kinetic.HitCanvas();
|
this.hitCanvas = new Kinetic.HitCanvas();
|
||||||
|
@@ -6,7 +6,6 @@ Test.Modules.STAGE = {
|
|||||||
height: 200
|
height: 200
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
'instantiate stage with dom element': function(containerId) {
|
'instantiate stage with dom element': function(containerId) {
|
||||||
var containerDom = document.getElementById(containerId);
|
var containerDom = document.getElementById(containerId);
|
||||||
var stage = new Kinetic.Stage({
|
var stage = new Kinetic.Stage({
|
||||||
@@ -15,6 +14,19 @@ Test.Modules.STAGE = {
|
|||||||
height: 200
|
height: 200
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
'stage instantiation should clear container': function(containerId) {
|
||||||
|
var container = document.getElementById(containerId);
|
||||||
|
var dummy = document.createElement('p');
|
||||||
|
container.appendChild(dummy);
|
||||||
|
|
||||||
|
var stage = new Kinetic.Stage({
|
||||||
|
container: containerId,
|
||||||
|
width: 578,
|
||||||
|
height: 200
|
||||||
|
});
|
||||||
|
|
||||||
|
test(container.getElementsByTagName('p').length === 0, 'container should have no p tags');
|
||||||
|
},
|
||||||
'set stage size': function(containerId) {
|
'set stage size': function(containerId) {
|
||||||
var stage = new Kinetic.Stage({
|
var stage = new Kinetic.Stage({
|
||||||
container: containerId,
|
container: containerId,
|
||||||
|
Reference in New Issue
Block a user