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

TypeError: Cannot read property "prototype" from undefined #44

Closed
binarykitchen opened this issue Dec 1, 2016 · 4 comments
Closed

TypeError: Cannot read property "prototype" from undefined #44

binarykitchen opened this issue Dec 1, 2016 · 4 comments

Comments

@binarykitchen
Copy link

seeing this error thrown in my app around these lines

// IE9-11 has no method "contains" in SVG element and in Node.prototype. Bug #10259.
var jqLiteContains = window.Node.prototype.contains || /** @this */ function(arg) {
  // eslint-disable-next-line no-bitwise
  return !!(this.compareDocumentPosition(arg) & 16);
};

happens with this user agent Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727)

@jgermade
Copy link
Member

jgermade commented Dec 1, 2016

Hi @binarykitchen, thanks for your feedback!

I'm a bit confused, this seems to be an angular.js issue, contains method is not provided by jqlite.

Could you provide a playground to test this behavior?

@binarykitchen
Copy link
Author

i am afraid, i cannot reduce this to a small test case. things in the angular code seem to be too bloated.

but i think we should add a check whether window.Node is defined. if not, then use that function.

@jgermade
Copy link
Member

Hi again @binarykitchen , I've added $.contains method to jqLite, maybe this can be helpful for you.

According to angular issue #10259, this behavior can be escaped with following snippet:

if (typeof SVGElement.prototype.contains == 'undefined') {
  SVGElement.prototype.contains = HTMLDivElement.prototype.contains;
}

In general, I prefer to avoid add hacks and polyfills to jqLite in order to avoid mistake libraries that detects browser support (like modernizr)

@SalilLambe
Copy link

@jgermade do i need to replace the buggy code

var jqLiteContains = window.Node.prototype.contains || /** @this */ function(arg) {
// eslint-disable-next-line no-bitwise
return !!(this.compareDocumentPosition(arg) & 16);
};

with if (typeof SVGElement.prototype.contains == 'undefined') {
SVGElement.prototype.contains = HTMLDivElement.prototype.contains;
}

or do it need to place it somewhere

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

3 participants