Comparing version 2.1.4 to 2.1.5
@@ -33,7 +33,7 @@ 'use strict'; | ||
this.parser = new Parser(options, this.scriptHandler.bind(this)); | ||
this.parser = new Parser(options); | ||
this.lastChunkWritten = false; | ||
this.writeCallback = null; | ||
this.parserLoopLock = false; | ||
this.pausedByScript = false; | ||
@@ -52,2 +52,3 @@ /** | ||
this._documentWrite = this._documentWrite.bind(this); | ||
this._scriptHandler = this._scriptHandler.bind(this); | ||
@@ -73,14 +74,7 @@ this.parser._bootstrap(this.document, null); | ||
ParserStream.prototype._runParsingLoop = function () { | ||
// NOTE: This helps avoid reentrant invocation of parsing loop | ||
// in cases then `resume` called synchronously | ||
// (see: https://github.com/inikulin/parse5/issues/98). | ||
if (!this.parserLoopLock) { | ||
this.parserLoopLock = true; | ||
this.parser._runParsingLoop(this.writeCallback); | ||
this.parserLoopLock = false; | ||
} | ||
this.parser._runParsingLoop(this.writeCallback, this._scriptHandler); | ||
}; | ||
ParserStream.prototype._resume = function () { | ||
if (!this.parser.pausedByScript) | ||
if (!this.pausedByScript) | ||
throw new Error('Parser was already resumed'); | ||
@@ -94,3 +88,3 @@ | ||
this.parser.pausedByScript = false; | ||
this.pausedByScript = false; | ||
@@ -107,5 +101,5 @@ //NOTE: keep parsing if we don't wait for the next input chunk | ||
ParserStream.prototype.scriptHandler = function (scriptElement) { | ||
ParserStream.prototype._scriptHandler = function (scriptElement) { | ||
if (this.listeners('script').length) { | ||
this.parser.pausedByScript = true; | ||
this.pausedByScript = true; | ||
@@ -148,3 +142,5 @@ /** | ||
} | ||
else | ||
this._runParsingLoop(); | ||
}; | ||
{ | ||
"name": "parse5", | ||
"description": "WHATWG HTML5 specification-compliant, fast and ready for production HTML parsing/serialization toolset for Node.js", | ||
"version": "2.1.4", | ||
"version": "2.1.5", | ||
"author": "Ivan Nikulin <ifaaan@gmail.com> (https://github.com/inikulin)", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -31,2 +31,6 @@ <p align="center"> | ||
<p align="center"> | ||
<a href="https://github.com/inikulin/parse5/wiki/Documentation#version-history">Version history</a> | ||
</p> | ||
<p align="center"> | ||
<a href="http://astexplorer.net/#/1CHlCXc4n4">Online playground</a> | ||
@@ -33,0 +37,0 @@ </p> |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
381074
7409
41