Merge pull request #210 from aronallen/fix/ie11svg

use parentNode instead of parentElement
pull/219/head
Simon Friis Vindum 8 years ago committed by GitHub
commit 7da866270a

@ -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;
}

@ -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;
}

@ -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);
});
})

@ -5,3 +5,4 @@ require('./eventlisteners');
require('./attachto');
require('./thunk');
require('./attributes');
require('./htmldomapi')
Loading…
Cancel
Save