Skip to content

make example of vm ready bug in phantom.js #764

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

Closed
wants to merge 1 commit into from

Conversation

tscanlin
Copy link

@tscanlin tscanlin commented Apr 3, 2015

@yyx990803 this doesn't seem to be a bug in the browser, but from phantom.js. I would expect the ready function for a child component to fire when running in phantom / casper, but it seems that it is not. I think the culprit is util.inDoc returning false. So maybe the version of webkit that phantom / casper use doesn't support document.documentElement.contains (at least for comments)?

One thing to note is that I am using windows...

overriding util.inDoc with $.contains seems to fix it. I'm gonna try to find a better way though.

@tscanlin
Copy link
Author

tscanlin commented Apr 3, 2015

Both of the below are taken from jquery and seem to work as ok replacements:

exports.inDoc = function (node) {
    var adown = doc.nodeType === 9 ? doc.documentElement : doc,
        bup = node && node.parentNode;
    return doc === bup || !!( bup && bup.nodeType === 1 && (
        adown.contains ?
            adown.contains( bup ) :
            doc.compareDocumentPosition && doc.compareDocumentPosition( bup ) & 16
        ));
}

---------- OR -----------

exports.inDoc = function (node) {
    if ( node ) {
        while ( (node = node.parentNode) ) {
            if ( node === doc ) {
                return true;
            }
        }
    }
    return false;
}

Let me know if there's a more appropriate place for this if you are able to confirm the issue. This PR isn't intended to be merged, just serve as an example to diagnose the problem.

@yyx990803
Copy link
Member

Nice! I've noticed this issue when running the unit tests in phantomjs and the first of your two implementations seem to be a good option. Do you want to open a PR for it?

@tscanlin
Copy link
Author

tscanlin commented Apr 5, 2015

Sure, I'd be happy to! Here's a PR: https://github.com/yyx990803/vue/pull/767

@tscanlin
Copy link
Author

tscanlin commented Apr 7, 2015

The fix for this was merged into dev in this PR: https://github.com/yyx990803/vue/pull/768

@tscanlin tscanlin closed this Apr 7, 2015
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

Successfully merging this pull request may close these issues.

2 participants