Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weinre style inspection not working with AngularJS

I'm trying to use Weinre to debug an AngularJS application, but the style inspection isn't working. I can use Weinre to select elements on the page, but it never shows the associated style information coming from CSS selectors. I've narrowed it down to simply including AngularJS (I'm using version 1.2.5) on the page breaks Weinre style inspection. I've found a few references online to Weinre not working with AngularJS (https://issues.apache.org/jira/browse/CB-2651) but the JIRAs say that it's resolved. Any ideas?

like image 962
chinabuffet Avatar asked Dec 20 '13 14:12

chinabuffet


2 Answers

Include the following function, and run it early on your page:

function whackWebkitMatchesSelector() {
    var oldMatches = Element.prototype.webkitMatchesSelector

    function newMatches(selector) {
        try {
            return oldMatches.call(this, selector)
        }
        catch (err) {
            return false
        }
    }

    Element.prototype.webkitMatchesSelector = newMatches
}

whackWebkitMatchesSelector()

As suggested in https://issues.apache.org/jira/browse/CB-6161 I can now inspect most (probably not all) styles.

like image 174
obiuquido144 Avatar answered Oct 08 '22 18:10

obiuquido144


They "fixed" it by catching the exception and continuing on. Apparently the issue is caused by (what webkit thinks) are invalid CSS selectors.

like image 38
Jeff Hubbard Avatar answered Oct 08 '22 18:10

Jeff Hubbard