-
Notifications
You must be signed in to change notification settings - Fork 421
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
Android - document.contains #686
Conversation
Does this mean your patch doesn't fix the issue, it's just something you think might be better? |
Oh, you are saying document.contains doesn't exist, but document.body.contain does. Ah, why not use document.documentElement? That way anything inserted works (even something in the head). |
Yep, why not; document.documentElement is document.childNodes[1]. As I said, I'm not sure it has some interest to check in the full HTML fragment (document.documentElement / document.childNodes[1]) as the HTML Head may reference quite lot of nodes (even more when we use an AMD loader like Require). But if some people may have interest to use can.inserted in order to check if an element is in the Head, then why not :) |
This seems to specifically occur when using Zepto (not if you run the tests without a library). |
I'm going to be adding a little tweak to your commit, then I'll merge it. |
"This seems to specifically occur when using Zepto (not if you run the tests without a library)." Also, you added a condition in order to continue to use contains on document; that's not right, if you want to check on the full document, then use document.documentElement, if you prefer to check only on body, then use document.body : then there is no need to add a condition as both works over all browsers. |
util/inserted/inserted.js provide can.inserted which checks if the given elements belong to the document DOM tree.
This rely on can.has which itself rely on the DOM library (zepto, jquery....) which rely on browser contains native method (at least for zepto).
document.contains isn't provided by android stock browser and so, can.inserted fails and so can.view can't render.
I assume it would be better to check on document.body instead of document.
It's possible to use contains from document.childNodes, so this contains check will also works over HTML (document.childNodes[1]), even if I don't see much interest to check in full HTML fragment.