Skip to content

Commit

Permalink
Merge 3a82058 into 374e7a7
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJaredWilcurt committed Feb 8, 2020
2 parents 374e7a7 + 3a82058 commit abbdd3a
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,13 @@ function removeServerRenderedText (html, options) {
function removeScopedStylesDataVIDAttributes (html, options) {
if (!options || options.removeDataVId) {
// [-\w]+ will catch 1 or more instaces of a-z, A-Z, 0-9, hyphen (-), or underscore (_)
const regexA = / data-v-[-\w]+=""/g;
const regexB = / data-v-[-\w]+/g;
const regex = / data-v-[-\w]+/g;

// [[' data-v-asdf=""'], [' data-v-qwer=""'], [' data-v-asdf=""']]
let dataVIdsA = Array.from(html.matchAll(regexA));
// [[' data-v-asdf'], [' data-v-qwer'], [' data-v-asdf']]
let dataVIdsB = Array.from(html.matchAll(regexB));
// [...dataVIdsA, ...dataVIdsB]
let dataVIds = [].concat(dataVIdsA, dataVIdsB);
// [' data-v-asdf=""', ' data-v-qwer', ' data-v-asdf']
let dataVIds = html.match(regex) || [];
// ['data-v-asdf', 'data-v-qwer', 'data-v-asdf']
dataVIds = dataVIds.map(function (match) {
return match[0].trim().replace('=""', '');
return match.trim().replace('=""', '');
});
// ['data-v-asdf', 'data-v-qwer']
dataVIds = Array.from(new Set(dataVIds));
Expand Down

0 comments on commit abbdd3a

Please sign in to comment.