Elm support for older browsers? (IE 9, 10, …) - update 0.19


#1

Hi all,
I’d like to update closed topic Elm support for older browsers? (IE 9, 10, …) .
After update elm to 0.19 we faced issue SCRIPT87: Invalid argument. index2.html, line 3410 character 8

case 7:
					var data = patch.s;
					var kids = data.e;
					var i = data.v;
					var theEnd = domNode.childNodes[i];
					for (; i < kids.length; i++) {
						domNode.insertBefore(_VirtualDom_render(kids[i], patch.u), theEnd);
					}
					return domNode;

It seems, that IE10 doesn’t accept null nor undefined as second argument. Our quick fix is for TS:

var originalInsertBefore = Node.prototype.insertBefore
    Node.prototype.insertBefore = function <T extends Node>(newChild: T, refChild: Node | null): T {
        try {
            return <T>originalInsertBefore.apply(this, [newChild, refChild])
        } catch (e) {
            return this.appendChild(newChild)
        }
    }

and JS:

	var originalInsertBefore = Node.prototype.insertBefore
	Node.prototype.insertBefore = function (arg1, arg2) {
		try {
			return originalInsertBefore.apply(this, arguments)
		} catch (e) {
			return this.appendChild(arg1)
		}
	}

Best Regards!
Ivo