Skip to content

Commit

Permalink
Ignore tags with null attributes
Browse files Browse the repository at this point in the history
Fixes an edge case that occurs when used with vue-cli.

Closes #122
  • Loading branch information
jscheid committed Apr 29, 2020
1 parent f47a7a2 commit b616def
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions test/test-misc.js
Expand Up @@ -17,6 +17,8 @@ var webpackVersion = Number(
require('webpack/package.json').version.split('.')[0]
);

var util = require('../util');

function testCompilation() {
return {
warnings: [],
Expand Down Expand Up @@ -311,4 +313,8 @@ describe('Plugin Options', function describe() {
expect(dummyCompilation.warnings[0].message).toMatch(
/Set webpack option output.crossOriginLoading/);
});

it('ignores tags without attributes', function it() {
expect(util.filterTag({ tagName: "script" })).toBeFalsy();
});
});
6 changes: 5 additions & 1 deletion util.js
Expand Up @@ -67,7 +67,11 @@ function getTagSrc(tag) {

function filterTag(tag) {
// Process only script and link tags with a url
return (tag.tagName === "script" || tag.tagName === "link") && getTagSrc(tag);
return (
(tag.tagName === "script" || tag.tagName === "link") &&
tag.attributes &&
getTagSrc(tag)
);
}

function normalizePath(p) {
Expand Down

0 comments on commit b616def

Please sign in to comment.