Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elm uses invalid value in domNode.insertBefore #161

Open
malaire opened this issue Nov 7, 2019 · 3 comments
Open

Elm uses invalid value in domNode.insertBefore #161

malaire opened this issue Nov 7, 2019 · 3 comments

Comments

@malaire
Copy link

malaire commented Nov 7, 2019

This Elm bug is seen when compiling (with --debug and Elm 0.19.1) the default counter-example of Ellie locally, and then running it with IE 10. IE 10 gives error "Invalid argument" at main.js, line 3710, character 5

The error happens on domNode.insertBefore line in following code:

		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;

Changing that line to following fixes this error:

				domNode.insertBefore(_VirtualDom_render(kids[i], patch.u), theEnd || null);

This confirms that Elm is using invalid value of theEnd, because only valid node or null is allowed there. So this is not a bug in IE 10, but a bug in Elm which is just seen in IE 10.

MDN documentation of insertBefore says:

referenceNode is not an optional parameter -- you must explicitly pass a Node or null. Failing to provide it or passing invalid values may behave differently in different browser versions.

@malaire
Copy link
Author

malaire commented Nov 7, 2019

Exact files used (just new project with elm init and direct copy from Ellie example). txt extension added as GitHub doesn't allow these otherwise.

elm.json.txt
index.html.txt
Main.elm.txt

ps. I don't have access to IE 10 for long enough to create better minimal example.

@malaire
Copy link
Author

malaire commented Nov 7, 2019

Testing with Firefox 68.2.0esr shows that just before the for-loop theEnd is undefined.

(So invalid value of theEnd is not limited to IE 10, it just doesn't cause problems e.g. in Firefox).

@seanstrom
Copy link

I'm also running into this issue where some implementations will prepend an element to the childNodes, or just throw an error, when given undefined as a value for the referenceNode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants