Bug 130161

Summary: Web Inspector: Classname stuff in WebInspector.displayNameForNode should join DOMTokenList classList instead of using string parsing and concatenation
Product: WebKit Reporter: James Craig <jcraig>
Component: Web InspectorAssignee: Nobody <webkit-unassigned>
Status: RESOLVED WONTFIX    
Severity: Normal CC: graouts, joepeck, timothy, webkit-bug-importer
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   

Description James Craig 2014-03-12 15:38:40 PDT
Web Inspector: Classname stuff in WebInspector.displayNameForNode should join DOMTokenList classList instead of using string parsing and concatenation. Unless I'm missing something, I expect this was just written before DOMTokenList classList was available.

    var classAttribute = node.getAttribute("class");
    if (classAttribute) {
        var classes = classAttribute.trim().split(/\s+/);
        var foundClasses = {};

        for (var i = 0; i < classes.length; ++i) {
            var className = classes[i];
            if (className && !(className in foundClasses)) {
                title += "." + className;
                foundClasses[className] = true;
            }
        }
    }
Comment 1 Timothy Hatcher 2014-03-12 17:11:28 PDT
node is not a real DOMNode, it is our DOMNode proxy. So we don't have access to classList unless we go to the injected script for it. That is why we do what we do here.
Comment 2 James Craig 2014-03-13 09:25:50 PDT
Gotcha. Makes sense.