Reputation: 6583
Problem: I'm getting following error reports from the webpage on production:
TypeErrores6-shim/es6-shim in process
null is not an object (evaluating 'n.parentNode.removeChild')
Question
On the low level, what is the most likely scenario?
n
is null
(whatever n
is) n.parentNode
is null
arg
is null
in n.parentNode.removeChild(arg)
More details (if relevant):
We're using Sentry error reporting system to report errors.
This error happens under Mobile Safari and Chrome Mobile.
The source maps seems to be broken so I don't know which line of es6-shim script the error refers to (and most likely it's es6-shim problem at all as there is no occurence of removeChild in es6-shim code).
Upvotes: 0
Views: 1748
Reputation: 1074335
You can easily set up all three situations to determine which it is (also on jsFiddle):
var n, p;
console.log("If n were null:")
try {
n = null;
n.parentNode.removeChild(null);
} catch (e1) {
console.log(e1.message);
}
console.log("If parentNode were null:")
try {
n = document.createElement("div");
n.parentNode.removeChild(null);
} catch (e2) {
console.log(e2.message);
}
console.log("If arg were null:")
try {
p = document.createElement("div");
n = document.createElement("div");
p.appendChild(n);
n.parentNode.removeChild(null);
} catch (e3) {
console.log(e3.message);
}
.as-console-wrapper {
max-height: 100% !important;
}
When I run that on mobile Chrome, I see:
If n were null: null is not an object (evaluating 'n.parentNode') If parentNode were null: null is not an object (evaluating 'n.parentNode.removeChild') If arg were null: Argument 1 ('child') to Node.removeChild must be an instance of Node
So it would appear that n.parentNode.removeChild(...)
is being called on an object referenced by n
where parentNode
is null
.
Although the error is reported in es6-shim, it's not likely to be an error in es6-shim itself (as you say, there's no removeNode
in es6-shim); it's more likely that it's being thrown from a callback provided to one of the es6-shim functions.
Upvotes: 2