parse5
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -0,1 +1,4 @@ | ||
## 1.4.1 | ||
* Fix: Location info handling for the implicitly generated `<html>` and `<body>` elements (GH [#44](https://github.com/inikulin/parse5/issues/44)). | ||
## 1.4.0 | ||
@@ -8,6 +11,6 @@ * Add: Parser [decodeHtmlEntities](https://github.com/inikulin/parse5#optionsdecodehtmlentities) option. | ||
## 1.3.2 | ||
* Fix: `<form>` processing in `<template>` (GH [#40](https://github.com/inikulin/parse5/issues/40)) | ||
* Fix: `<form>` processing in `<template>` (GH [#40](https://github.com/inikulin/parse5/issues/40)). | ||
## 1.3.1 | ||
* Fix: text node in `<template>` serialization problem with custom tree adapter (GH [#38](https://github.com/inikulin/parse5/issues/38)) | ||
* Fix: text node in `<template>` serialization problem with custom tree adapter (GH [#38](https://github.com/inikulin/parse5/issues/38)). | ||
@@ -36,9 +39,9 @@ ## 1.3.0 | ||
## 1.1.2 | ||
* Fix: crash on Linux due to upper-case leading character in module name used in `require()` | ||
* Fix: crash on Linux due to upper-case leading character in module name used in `require()`. | ||
## 1.1.1 | ||
* Add: [SimpleApiParser](https://github.com/inikulin/parse5/#class-simpleapiparser) | ||
* Fix: new line serialization in `<pre>` | ||
* Fix: `SYSTEM`-only `DOCTYPE` serialization | ||
* Fix: quotes serialization in `DOCTYPE` IDs | ||
* Add: [SimpleApiParser](https://github.com/inikulin/parse5/#class-simpleapiparser). | ||
* Fix: new line serialization in `<pre>`. | ||
* Fix: `SYSTEM`-only `DOCTYPE` serialization. | ||
* Fix: quotes serialization in `DOCTYPE` IDs. | ||
@@ -45,0 +48,0 @@ ## 1.0.0 |
@@ -11,11 +11,12 @@ 'use strict'; | ||
function setEndLocation(element, endTagToken) { | ||
if (element.__location) | ||
element.__location.end = endTagToken.location.end; | ||
} | ||
//NOTE: patch open elements stack, so we can assign end location for the elements | ||
function patchOpenElementsStack(stack, parser) { | ||
function setEndLocation(element) { | ||
if (element.__location) | ||
element.__location.end = parser.currentToken.location.end; | ||
} | ||
stack.pop = function () { | ||
setEndLocation(this.current); | ||
setEndLocation(this.current, parser.currentToken); | ||
OpenElementStack.prototype.pop.call(this); | ||
@@ -26,3 +27,3 @@ }; | ||
for (var i = this.stackTop; i > 0; i--) | ||
setEndLocation(this.items[i]); | ||
setEndLocation(this.items[i], parser.currentToken); | ||
@@ -33,3 +34,3 @@ OpenElementStack.prototype.popAllUpToHtmlElement.call(this); | ||
stack.remove = function (element) { | ||
setEndLocation(element); | ||
setEndLocation(element, parser.currentToken); | ||
OpenElementStack.prototype.remove.call(this, element); | ||
@@ -72,3 +73,3 @@ }; | ||
if (this.treeAdapter.getTagName(element) === token.tagName) { | ||
element.__location.end = token.location.end; | ||
setEndLocation(element, token); | ||
break; | ||
@@ -75,0 +76,0 @@ } |
{ | ||
"name": "parse5", | ||
"description": "WHATWG HTML5 specification-compliant, fast and ready for production HTML parsing/serialization toolset for Node.", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"author": "Ivan Nikulin <ifaaan@gmail.com> (https://github.com/inikulin)", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -78,3 +78,3 @@ <p align="center"> | ||
##### options.locationInfo | ||
Enables source code location information for the nodes. Default: `false`. When enabled, each node (except root node) has `__location` property, which contains `start` and `end` indices of the node in the source code. | ||
Enables source code location information for the nodes. Default: `false`. When enabled, each node (except root node) has `__location` property, which contains `start` and `end` indices of the node in the source code. If element was implicitly created by the parser it's `__location` property will be `null`. | ||
@@ -81,0 +81,0 @@ *Example:* |
397213