Permalink
Browse files

Merge pull request #210 from aronallen/fix/ie11svg

use parentNode instead of parentElement
  • Loading branch information...
2 parents 3bd0068 + d8bd32f commit 7da866270a447b59ecf784a68e64d71949a4a400 @paldepind paldepind committed on GitHub Jan 3, 2017
Showing with 30 additions and 5 deletions.
  1. +1 −1 src/helpers/attachto.ts
  2. +4 −4 src/htmldomapi.ts
  3. +24 −0 test/htmldomapi.js
  4. +1 −0 test/index.js
@@ -16,7 +16,7 @@ function post(_: any, vnode: VNode): void {
function destroy(vnode: VNode): void {
// Remove placeholder
- vnode.elm && vnode.elm.parentElement.removeChild(vnode.elm);
+ vnode.elm && vnode.elm.parentNode && vnode.elm.parentNode.removeChild(vnode.elm);
// Remove real element from where it was inserted
vnode.elm = (vnode.data as VNodeData).attachData.real;
}
View
@@ -5,7 +5,7 @@ export interface DOMAPI {
insertBefore: (parentNode: Node, newNode: Node, referenceNode: Node | null) => void;
removeChild: (node: Node, child: Node) => void;
appendChild: (node: Node, child: Node) => void;
- parentNode: (node: Node) => HTMLElement;
+ parentNode: (node: Node) => Node;
nextSibling: (node: Node) => Node;
tagName: (elm: Element) => string;
setTextContent: (node: Node, text: string | null) => void;
@@ -35,11 +35,11 @@ function appendChild(node: Node, child: Node): void {
node.appendChild(child);
}
-function parentNode(node: Node): HTMLElement {
- return node.parentElement;
+function parentNode(node: Node): Node | null {
+ return node.parentNode;
}
-function nextSibling(node: Node): Node {
+function nextSibling(node: Node): Node | null {
return node.nextSibling;
}
View
@@ -0,0 +1,24 @@
+var assert = require('assert');
+
+var snabbdom = require('../snabbdom');
+var h = require('../h').default;
+var patch = snabbdom.init([]);
+
+describe('svg', function () {
+ var elm, vnode0;
+ beforeEach(function() {
+ elm = document.createElement('svg');
+ vnode0 = elm;
+ });
+ it('removes child svg elements', function(){
+ var a = h('svg', {}, [
+ h('g'),
+ h('g')
+ ]);
+ var b = h('svg', {}, [
+ h('g')
+ ]);
+ var result = patch(patch(vnode0, a), b).elm;
+ assert.equal(result.childNodes.length, 1);
+ });
+})
View
@@ -5,3 +5,4 @@ require('./eventlisteners');
require('./attachto');
require('./thunk');
require('./attributes');
+require('./htmldomapi')

0 comments on commit 7da8662

Please sign in to comment.