Skip to content

Commit

Permalink
Add (failing) test for stripping type attribute from ES module scri…
Browse files Browse the repository at this point in the history
…pt tags
  • Loading branch information
twome committed Mar 30, 2019
1 parent 2f1091a commit cb975b2
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
43 changes: 43 additions & 0 deletions packages/core/integration-tests/test/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,49 @@ describe('html', function() {
assert(html.includes('alert("Hello, World!")'));
});

it('should strip `type` attribute from ES-module and "text/javascript" script tags', async function() {
let b = await bundle(
path.join(__dirname, '/integration/html-module-type-scripts/index.html'),
{production: true}
);

await assertBundleTree(b, {
name: 'index.html',
assets: ['index.html'],
childBundles: [
{
type: 'js',
assets: ['module.js'],
childBundles: [
{
type: 'map'
}
]
},
{
type: 'js',
assets: ['text-javascript.js'],
childBundles: [
{
type: 'map'
}
]
}
]
});

let html = await fs.readFile(
path.join(__dirname, '/dist/index.html'),
'utf8'
);

console.debug(html);

assert(
!/type\s*=/.test(html) // No type="" attribute anywhere
);
});

it('should handle inline css with @imports', async function() {
let b = await bundle(
path.join(__dirname, '/integration/html-inline-css-import/index.html'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">

<head>
<title>Script tag type stripping - Parcel</title>

<script type="module" src="./module.js"></script>
<script type="text/javascript" src="./text-javascript.js"></script>
</head>

<body>
<h1>Hello world</h1>
</body>

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var a = 1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var b = 2

0 comments on commit cb975b2

Please sign in to comment.