Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore tags with null attributes #123

Merged
merged 1 commit into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions test/test-misc.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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