-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #RWEB_0041 - Do not modify the DOM when traversing it
- Loading branch information
Showing
5 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* @license | ||
* Copyright 2020 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import NoDocWriteAudit from 'lighthouse/core/audits/dobetterweb/no-document-write.js' | ||
import ViolationAudit from 'lighthouse/core/audits/violation-audit.js' | ||
import refsURLS from './refs-urls.js' | ||
|
||
class NoDocWriteCustomAudit extends ViolationAudit { | ||
static get meta() { | ||
const meta = NoDocWriteAudit.meta | ||
|
||
return { | ||
...meta, | ||
id: 'bp-no-document-write', | ||
title: '#RWEB_0041 - Do not modify the DOM when traversing it', | ||
failureTitle: '#RWEB_0041 - DOM modified.', | ||
description: `Modifying the DOM (Document Object Model) when traversing it can lead to situations where the loop becomes very resource-hungry, particularly in terms of CPU cycles. Indeed, if you add elements while traversing it, you may generate an infinite loop that will consume a large amount of resources. This type of modification is therefore strongly discouraged. [See #RWEB_0041](${refsURLS.rweb.bp_0041.en})`, | ||
} | ||
} | ||
|
||
static audit(artifacts, context) { | ||
return NoDocWriteAudit.audit(artifacts, context) | ||
} | ||
} | ||
|
||
export default NoDocWriteCustomAudit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters