Skip to content

Commit

Permalink
fix: TypeError: Cannot read property 'parentNode' of undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
halwu(吴浩麟) committed Jul 7, 2017
1 parent 00b33fd commit a9f66ac
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion demo/watch-template/dist/index.html
Expand Up @@ -6,7 +6,7 @@
<!--load a chunk file config and output in webpack-->
<script src="B.js"></script>
<!--load a local reset style file direct without local var webpack-->
<style>body {
<style rel="stylesheet">body {
background-color: rebeccapurple;
}</style>
<!--load a local google analyze file direct without local var webpack-->
Expand Down
4 changes: 2 additions & 2 deletions lib/WebPlugin.js
Expand Up @@ -117,8 +117,8 @@ class WebPlugin {
scriptResource.out(compilation);
});
// out styles to html document
this.htmlDocument.stylesResources.forEach(scriptResource => {
scriptResource.out(compilation);
this.htmlDocument.stylesResources.forEach(styleResource => {
styleResource.out(compilation);
});
// out others to html document
this.htmlDocument.otherResources.forEach(otherResource => {
Expand Down
4 changes: 4 additions & 0 deletions lib/util.js
Expand Up @@ -98,6 +98,10 @@ function isHotUpdateCompilation(compilation) {
* @param newNodes new nodes will insert into oldNodes's position
*/
function replaceNodesWithNodes(oldNodes, newNodes = []) {
// can't find oldNodes in document now
if (oldNodes.length === 0) {
return;
}
const childNodes = oldNodes[0].parentNode.childNodes;
let index = 0;
oldNodes.forEach(oldNode => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "web-webpack-plugin",
"version": "1.8.3",
"version": "1.8.4",
"description": "web plugin for webpack, alternatives for html-webpack-plugin, use HTML as entry",
"keywords": [
"webpack",
Expand Down

0 comments on commit a9f66ac

Please sign in to comment.