Skip to content

Commit

Permalink
#9048 Fix Avoid an excess DOM size error
Browse files Browse the repository at this point in the history
  • Loading branch information
NickolasBenakis committed May 29, 2019
1 parent ff4f486 commit a5f9343
Show file tree
Hide file tree
Showing 2 changed files with 14,993 additions and 10 deletions.
22 changes: 12 additions & 10 deletions lighthouse-core/lib/page-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,20 @@ function getElementsInDocument(selector) {
*/
/* istanbul ignore next */
function getOuterHTMLSnippet(element, ignoreAttrs = []) {
const clone = element.cloneNode();

ignoreAttrs.forEach(attribute =>{
clone.removeAttribute(attribute);
});

const reOpeningTag = /^[\s\S]*?>/;
const match = clone.outerHTML.match(reOpeningTag);

return (match && match[0]) || '';
try {
const clone = element.cloneNode();
ignoreAttrs.forEach(attribute =>{
clone.removeAttribute(attribute);
});
const reOpeningTag = /^[\s\S]*?>/;
const match = clone.outerHTML.match(reOpeningTag);
return (match && match[0]) || '';
} catch (error) {
return element.localName;
}
}


/**
* Computes a memory/CPU performance benchmark index to determine rough device class.
* @see https://docs.google.com/spreadsheets/d/1E0gZwKsxegudkjJl8Fki_sOwHKpqgXwt8aBAfuUaB8A/edit?usp=sharing
Expand Down
Loading

0 comments on commit a5f9343

Please sign in to comment.