src/LiveDevelopment/MultiBrowserImpl/language/HTMLInstrumentation.js
function walk(node) {
            if (node.tag) {
                var attrText = " data-brackets-id='" + node.tagID + "'";

                // If the dom was fully rebuilt, use its offsets. Otherwise, use the marks in the
                // associated editor, since they'll be more up to date.
                var startOffset;
                if (dom.fullBuild) {
                    startOffset = node.start;
                } else {
                    var mark = markCache[node.tagID];
                    if (mark) {
                        startOffset = editor._codeMirror.indexFromPos(mark.range.from);
                    } else {
                        console.warn("generateInstrumentedHTML(): couldn't find existing mark for tagID " + node.tagID);
                        startOffset = node.start;
                    }
                }

                // Insert the attribute as the first attribute in the tag.
                var insertIndex = startOffset + node.tag.length + 1;
                gen += orig.substr(lastIndex, insertIndex - lastIndex) + attrText;
                lastIndex = insertIndex;

                // If we have a script to inject and this is the head tag, inject it immediately
                // after the open tag.
                if (remoteScript && !remoteScriptInserted && node.tag === "head") {
                    insertIndex = node.openEnd;
                    gen += orig.substr(lastIndex, insertIndex - lastIndex) + remoteScript;
                    lastIndex = insertIndex;
                    remoteScriptInserted = true;
                }
            }

            if (node.isElement()) {
                node.children.forEach(walk);
            }
        }
function walk(node) {
            if (node.tag) {
                var attrText = " data-brackets-id='" + node.tagID + "'";

                // If the dom was fully rebuilt, use its offsets. Otherwise, use the marks in the
                // associated editor, since they'll be more up to date.
                var startOffset;
                if (dom.fullBuild) {
                    startOffset = node.start;
                } else {
                    var mark = markCache[node.tagID];
                    if (mark) {
                        startOffset = editor._codeMirror.indexFromPos(mark.range.from);
                    } else {
                        console.warn("generateInstrumentedHTML(): couldn't find existing mark for tagID " + node.tagID);
                        startOffset = node.start;
                    }
                }

                // Insert the attribute as the first attribute in the tag.
                var insertIndex = startOffset + node.tag.length + 1;
                gen += orig.substr(lastIndex, insertIndex - lastIndex) + attrText;
                lastIndex = insertIndex;

                // If we have a script to inject and this is the head tag, inject it immediately
                // after the open tag.
                if (remoteScript && !remoteScriptInserted && node.tag === "head") {
                    insertIndex = node.openEnd;
                    gen += orig.substr(lastIndex, insertIndex - lastIndex) + remoteScript;
                    lastIndex = insertIndex;
                    remoteScriptInserted = true;
                }
            }

            if (node.isElement()) {
                node.children.forEach(walk);
            }
        }
function walk ( node ) { if ( node . tag ) { var attrText = " data-brackets-id='" + node . tagID + "'" ; // If the dom was fully rebuilt, use its offsets. Otherwise, use the marks in the // associated editor, since they'll be more up to date. var startOffset ; if ( dom . fullBuild ) { startOffset = node . start ; } else { var mark = markCache [ node . tagID ] ; if ( mark ) { startOffset = editor . _codeMirror . indexFromPos ( mark . range . from ) ; } else { console . warn ( "generateInstrumentedHTML(): couldn't find existing mark for tagID " + node . tagID ) ; startOffset = node . start ; } } // Insert the attribute as the first attribute in the tag. var insertIndex = startOffset + node . tag . length + 1 ; gen += orig . substr ( lastIndex , insertIndex - lastIndex ) + attrText ; lastIndex = insertIndex ; // If we have a script to inject and this is the head tag, inject it immediately // after the open tag. if ( remoteScript && ! remoteScriptInserted && node . tag === "head" ) { insertIndex = node . openEnd ; gen += orig . substr ( lastIndex , insertIndex - lastIndex ) + remoteScript ; lastIndex = insertIndex ; remoteScriptInserted = true ; } } if ( node . isElement ( ) ) { node . children . forEach ( walk ) ; } }
Walk through the dom nodes and insert the 'data-brackets-id' attribute at the end of the open tag
Walk through the dom nodes and insert the data - brackets - id attribute at the end of the open tag