Skip to content

Commit 914c4eb

Browse files
committed
refactor: changed value of a config key
1 parent 6c26d3c commit 914c4eb

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

lib/config.defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
'link[rel="preload"][as="script"]',
1313
'script:not([type="application/ld+json"])',
1414
],
15-
classesToKeep: null, // disallow pruning of scripts with this class (could be an array of classes), N.B.: each `classesToKeep` will be appended to every `selectors`, ex.: `script:not([type="application/ld+json"]):not(__classesToKeep__)`
15+
classesSelectorsToKeep: [], // disallow pruning of scripts with this class (could be an array of classes), N.B.: each `classesToKeep` will be appended to every `selectors`, ex.: `script:not([type="application/ld+json"]):not(__classesToKeep__)`
1616
link: [], // Inject custom links, only if pruned
1717
script: [], // Inject custom scripts, only if pruned
1818
htmlElementClass: null, // this is a string added as a class to the <html> element

lib/config.deprecated.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ export default {
66
isLighthouse: '@deprecated since version 2.0.0, use `isAudit` instead',
77
ignoreBotOrLighthouse: '@deprecated since version 2.0.0, use `isAudit` instead',
88
lighthouseUserAgent: '@deprecated since version 2.0.0, use `auditUserAgent` instead',
9-
selectorToKeep: '@deprecated since version 2.0.0, use `classesToKeep` instead',
9+
selectorToKeep: '@deprecated since version 2.0.0, use `classesSelectorsToKeep` instead',
1010
};

lib/module.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,8 @@ export default function nuxtPruneHtml(
8888
if( isOldOrInvalidConfig ) {
8989

9090
logAnError(
91-
'please, upgrade your configuration, there are some deprecation warnings',
91+
'please, upgrade your configuration, there are some deprecation warnings, the plugin will stop its execution',
9292
deprecatedConfig,
93-
true
9493
);
9594

9695
return;
@@ -107,7 +106,7 @@ export default function nuxtPruneHtml(
107106
{
108107
cheerio: cheerioConfig = {},
109108
selectors = [],
110-
classesToKeep = [],
109+
classesSelectorsToKeep = [],
111110
script = [],
112111
link = [],
113112
types = [],
@@ -119,7 +118,7 @@ export default function nuxtPruneHtml(
119118
return '';
120119

121120
// Selector to selectors (in case of array)
122-
const classesToKeepToArray = stringToArray( classesToKeep );
121+
const classesSelectorsToKeepToArray = stringToArray( classesSelectorsToKeep );
123122

124123
// Let's prune
125124
try {
@@ -133,8 +132,8 @@ export default function nuxtPruneHtml(
133132
// Selector to prune/keep
134133
for( const s of selectors ) {
135134

136-
if( classesToKeepToArray.length )
137-
classesToKeepToArray.forEach( keepMe => $( `${ s }:not(${ keepMe })` ).remove() );
135+
if( classesSelectorsToKeepToArray.length )
136+
classesSelectorsToKeepToArray.forEach( keepMe => $( `${ s }:not(${ keepMe })` ).remove() );
138137
else
139138
$( s ).remove();
140139

0 commit comments

Comments
 (0)