function scanDocument(doc) {
        if (!_cachedValues.hasOwnProperty(doc.file.fullPath)) {
            // TODO: this doesn't seem to be correct any more. The DOM should never be "dirty" (i.e., out of sync
            // with the editor) unless the doc is invalid.
//            $(doc).on("change.htmlInstrumentation", function () {
//                if (_cachedValues[doc.file.fullPath]) {
//                    _cachedValues[doc.file.fullPath].dirty = true;
//                }
//            });

            // Assign to cache, but don't set a value yet
            _cachedValues[doc.file.fullPath] = null;
        }

        var cachedValue = _cachedValues[doc.file.fullPath];
        // TODO: No longer look at doc or cached value "dirty" settings, because even if the doc is dirty, the dom
        // should generally be up to date unless the HTML is invalid. (However, the node offsets will be dirty of
        // the dom was incrementally updated - we should note that somewhere.)
        if (cachedValue && !cachedValue.invalid && cachedValue.timestamp === doc.diskTimestamp) {
            return cachedValue.dom;
        }

        var text = doc.getText(),
            dom = HTMLSimpleDOM.build(text);

        if (dom) {
            // Cache results
            _cachedValues[doc.file.fullPath] = {
                timestamp: doc.diskTimestamp,
                dom: dom,
                dirty: false
            };
            // Note that this was a full build, so we know that we can trust the node start/end offsets.
            dom.fullBuild = true;
        }

        return dom;
    }
function scanDocument(doc) {
        if (!_cachedValues.hasOwnProperty(doc.file.fullPath)) {
            // TODO: this doesn't seem to be correct any more. The DOM should never be "dirty" (i.e., out of sync
            // with the editor) unless the doc is invalid.
//            $(doc).on("change.htmlInstrumentation", function () {
//                if (_cachedValues[doc.file.fullPath]) {
//                    _cachedValues[doc.file.fullPath].dirty = true;
//                }
//            });

            // Assign to cache, but don't set a value yet
            _cachedValues[doc.file.fullPath] = null;
        }

        var cachedValue = _cachedValues[doc.file.fullPath];
        // TODO: No longer look at doc or cached value "dirty" settings, because even if the doc is dirty, the dom
        // should generally be up to date unless the HTML is invalid. (However, the node offsets will be dirty of
        // the dom was incrementally updated - we should note that somewhere.)
        if (cachedValue && !cachedValue.invalid && cachedValue.timestamp === doc.diskTimestamp) {
            return cachedValue.dom;
        }

        var text = doc.getText(),
            dom = HTMLSimpleDOM.build(text);

        if (dom) {
            // Cache results
            _cachedValues[doc.file.fullPath] = {
                timestamp: doc.diskTimestamp,
                dom: dom,
                dirty: false
            };
            // Note that this was a full build, so we know that we can trust the node start/end offsets.
            dom.fullBuild = true;
        }

        return dom;
    }
function scanDocument ( doc ) { if ( ! _cachedValues . hasOwnProperty ( doc . file . fullPath ) ) { // TODO: this doesn't seem to be correct any more. The DOM should never be "dirty" (i.e., out of sync // with the editor) unless the doc is invalid. //            $(doc).on("change.htmlInstrumentation", function () { //                if (_cachedValues[doc.file.fullPath]) { //                    _cachedValues[doc.file.fullPath].dirty = true; //                } //            }); // Assign to cache, but don't set a value yet _cachedValues [ doc . file . fullPath ] = null ; } var cachedValue = _cachedValues [ doc . file . fullPath ] ; // TODO: No longer look at doc or cached value "dirty" settings, because even if the doc is dirty, the dom // should generally be up to date unless the HTML is invalid. (However, the node offsets will be dirty of // the dom was incrementally updated - we should note that somewhere.) if ( cachedValue && ! cachedValue . invalid && cachedValue . timestamp === doc . diskTimestamp ) { return cachedValue . dom ; } var text = doc . getText ( ) , dom = HTMLSimpleDOM . build ( text ) ; if ( dom ) { // Cache results _cachedValues [ doc . file . fullPath ] = { timestamp : doc . diskTimestamp , dom : dom , dirty : false } ; // Note that this was a full build, so we know that we can trust the node start/end offsets. dom . fullBuild = true ; } return dom ; }
Parses the document, returning an HTMLSimpleDOM structure and caching it as the
initial state of the document. Will return a cached copy of the DOM if the
document hasn't changed since the last time scanDocument was called.

This is called by generateInstrumentedHTML(), but it can be useful to call it
ahead of time so the DOM is cached and doesn't need to be rescanned when the
instrumented HTML is requested by the browser.

@param {Document} doc The doc to scan.
@return {Object} Root DOM node of the document.
Parses the document returning an HTMLSimpleDOM structure and caching it as the initial state of the document . Will return a cached copy of the DOM if the document hasn t changed since the last time scanDocument was called .
Scans the document and returns the DOM