Permalink
Browse files

Added options parameter to parser contructor

  • Loading branch information...
tautologistics committed Nov 17, 2010
1 parent db19613 commit b12edc58dade4bb6241639ecf02780b0709e98fa
Showing with 11 additions and 5 deletions.
  1. +9 −3 lib/node-htmlparser.js
  2. +2 −2 lib/node-htmlparser.min.js
View
@@ -18,7 +18,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
***********************************************/
-/* v1.6.4 */
+/* v1.7.0 */
(function () {
@@ -55,7 +55,12 @@ var ElementType = {
, Tag: "tag" //Any tag that isn't special
}
-function Parser (handler) {
+function Parser (handler, options) {
+ this._options = options ? options : { };
+ if (this._options.includeLocation == undefined) {
+ this._options.includeLocation = false; //Do not track element position in document by default
+ }
+
this.validateHandler(handler);
this._handler = handler;
this.reset();
@@ -136,6 +141,7 @@ function Parser (handler) {
//**Private**//
//Properties//
+ Parser.prototype._options = null; //Parser options for how to behave
Parser.prototype._handler = null; //Handler for parsed elements
Parser.prototype._buffer = null; //Buffer of unparsed data
Parser.prototype._done = false; //Flag indicating whether parsing is done
@@ -219,7 +225,7 @@ function Parser (handler) {
, type: this._parseState
};
- if (this.includeLocation) {
+ if (this._options.includeLocation) {
element.location = this.getLocation();
}
Oops, something went wrong.

0 comments on commit b12edc5

Please sign in to comment.