From a4346c610d72fd85abf6465811b9c413c3d19c8f Mon Sep 17 00:00:00 2001 From: Rune Madsen Date: Thu, 28 Sep 2017 19:38:43 +0800 Subject: [PATCH] updating changelog --- CHANGELOG.md | 1 + dist/rune.js | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a14b62..02bfec7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 1.1.1 - Calling `remove` on a group with a shape that is not in the group will not remove another shape in the group. +- Adding `viewBox` attribute on resulting SVG. ## 1.1.0 diff --git a/dist/rune.js b/dist/rune.js index 6f71e72..75c48ad 100644 --- a/dist/rune.js +++ b/dist/rune.js @@ -2631,9 +2631,19 @@ var Parent = { }, removeChild: function(child) { + + if(child.parent !== this) { + return; + } + + // check if it is in this parent this.renderedChildren.splice(child.childId, 1); this.children.splice(child.childId, 1); - this.changedChildren = without(this.changedChildren, child.childId); + + var childIndex = this.changedChildren.indexOf(child.childId); + if(childIndex !== -1) { + this.changedChildren.splice(childIndex, 1); + } // Lower id's of all children above by one for(var i = child.childId; i < this.children.length; i++) { @@ -3079,10 +3089,14 @@ var Rune = function(options) { this.height = params.height; } + if(attrs.width && attrs.height) { + attrs.viewBox = '0 0 ' + attrs.width + ' ' + attrs.height; + } + var props = { - attributes: attrs + attributes: attrs } - + this.tree = svg('svg', props); this.el = createElement(this.tree); this.stage = new Group(); @@ -3282,7 +3296,7 @@ Rune.prototype = { var props = { attributes: attrs } - + var newTree = svg('svg', props, [this.stage.renderChildren({ debug: this.debug })]); var diffTree = diff(this.tree, newTree); this.el = patch(this.el, diffTree);