Skip to content

Commit

Permalink
Added options parameter to parser contructor
Browse files Browse the repository at this point in the history
  • Loading branch information
tautologistics committed Nov 17, 2010
1 parent db19613 commit b12edc5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions lib/node-htmlparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -219,7 +225,7 @@ function Parser (handler) {
, type: this._parseState
};

if (this.includeLocation) {
if (this._options.includeLocation) {
element.location = this.getLocation();
}

Expand Down
Loading

0 comments on commit b12edc5

Please sign in to comment.