html-dom-parser
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -5,21 +5,27 @@ # Change Log | ||
The format is based on [Keep a Changelog](http://keepachangelog.com) and this project adheres to [Semantic Versioning](http://semver.org). | ||
The format is based on [Keep a Changelog](http://keepachangelog.com) | ||
and this project adheres to [Semantic Versioning](http://semver.org). | ||
## Todo | ||
- Set up karma testing for client parser (karma-commonjs) | ||
- Change test strategy for server (mock or spy on `htmlparser2` and `domhandler` instead of running through fixtures) | ||
- Use sinon or change test framework to jasmine (in order to spy on required modules) | ||
## [0.1.1](https://github.com/remarkablemark/html-dom-parser/compare/v0.1.0...v0.1.1) - 2017-06-26 | ||
### Added | ||
- CHANGELOG with previous releases backfilled | ||
- Upgrade package dependencies with `ncu` (may require minor bump) | ||
- Backfill changelog | ||
- Build sourcemap using webpack | ||
### Fixed | ||
- Fix client parser on IE by specifying required parameter for `createHTMLDocument` (#4) | ||
## 0.0.2 - 2016-10-10 | ||
## [0.0.2](https://github.com/remarkablemark/html-dom-parser/compare/v0.0.1...v0.0.2) - 2016-10-10 | ||
### Added | ||
- Feature | ||
- Create npm scripts for prepublish | ||
## 0.0.1 - 2016-10-10 | ||
### Changed | ||
- Change webpack to build to UMD target | ||
- Update README installation and usage instructions | ||
## [0.0.1](https://github.com/remarkablemark/html-dom-parser/tree/v0.0.1) - 2016-10-10 | ||
### Added | ||
- Feature | ||
- Server parser | ||
- Wrapper for `htmlparser2.parseDOM` | ||
- Client parser | ||
- Uses DOM API to mimic server parser output | ||
- Build client library with webpack | ||
- Add README, tests, and other necessary files |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.HTMLDOMParser=t():e.HTMLDOMParser=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var a=n[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t,n){"use strict";var r,a=/<([a-zA-Z]+[0-9]?)/,o=/<head[\s\S]*>[\s\S]*<\/head>/i,i=/<body[\s\S]*>[\s\S]*<\/body>/i;if("function"==typeof window.DOMParser){var u=new window.DOMParser;r=function(e,t){return t&&(e=["<",t,">",e,"</",t,">"].join("")),u.parseFromString(e,"text/html")}}var s;if("object"==typeof document.implementation){var c=document.implementation.createHTMLDocument();s=function(e,t){return t?c.documentElement.getElementsByTagName(t)[0].innerHTML=e:c.documentElement.innerHTML=e,c}}var d,l=document.createElement("template");l.content&&(d=function(e){return l.innerHTML=e,l.content.childNodes});var m=s||r;e.exports=function(e){var t,n=e.match(a);n&&n[1]&&(t=n[1]);var u,s,c;switch(t){case"html":if(r)return u=r(e),o.test(e)||(s=u.getElementsByTagName("head")[0],s.parentNode.removeChild(s)),i.test(e)||(s=u.getElementsByTagName("body")[0],s.parentNode.removeChild(s)),u.getElementsByTagName("html");break;case"head":if(m)return c=m(e).getElementsByTagName("head"),i.test(e)?c[0].parentNode.childNodes:c;break;case"body":if(m)return c=m(e).getElementsByTagName("body"),o.test(e)?c[0].parentNode.childNodes:c;break;default:if(d)return d(e);if(m)return m(e,"body").getElementsByTagName("body")[0].childNodes}return[]}},function(e,t,n){"use strict";function r(e){for(var t,n={},r=0,a=e.length;r<a;r++)t=e[r],n[t.name]=t.value;return n}function a(e,t,n){t=t||null;for(var o,i,u,s=[],c=0,d=e.length;c<d;c++){switch(o=e[c],u={next:null,prev:s[c-1]||null,parent:t},i=s[c-1],i&&(i.next=u),0!==o.nodeName.indexOf("#")&&(u.name=o.nodeName.toLowerCase(),u.attribs={},o.attributes&&o.attributes.length&&(u.attribs=r(o.attributes))),o.nodeType){case 1:"script"===u.name||"style"===u.name?u.type=u.name:u.type="tag",u.children=a(o.childNodes,u);break;case 3:u.type="text",u.data=o.nodeValue;break;case 8:u.type="comment",u.data=o.nodeValue}s.push(u)}return n&&(s.unshift({name:n.substring(0,n.indexOf(" ")).toLowerCase(),data:n,type:"directive",next:s[0]?s[0]:null,prev:null,parent:t}),s[1]&&(s[1].prev=s[0])),s}e.exports={formatAttributes:r,formatDOM:a}},function(e,t,n){"use strict";var r=n(0),a=n(1),o=a.formatDOM,i=/<(![a-zA-Z\s]+)>/;e.exports=function(e){if("string"!=typeof e)throw new TypeError("First argument must be a string.");if(!e)return[];var t,n=e.match(i);return n&&n[1]&&(t=n[1]),o(r(e),null,t)}}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.HTMLDOMParser=t():e.HTMLDOMParser=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t,n){"use strict";var r,o=/<([a-zA-Z]+[0-9]?)/,a=/<head[\s\S]*>[\s\S]*<\/head>/i,i=/<body[\s\S]*>[\s\S]*<\/body>/i;if("function"==typeof window.DOMParser){var u=new window.DOMParser;r=function(e,t){return t&&(e=["<",t,">",e,"</",t,">"].join("")),u.parseFromString(e,"text/html")}}var s;if("object"==typeof document.implementation){var c=document.implementation.createHTMLDocument("title");c.documentElement.innerHTML="",s=function(e,t){return t?c.documentElement.getElementsByTagName(t)[0].innerHTML=e:c.documentElement.innerHTML=e,c}}var d,l=document.createElement("template");l.content&&(d=function(e){return l.innerHTML=e,l.content.childNodes});var m=s||r;e.exports=function(e){var t,n=e.match(o);n&&n[1]&&(t=n[1]);var u,s,c;switch(t){case"html":if(r)return u=r(e),a.test(e)||(s=u.getElementsByTagName("head")[0],s.parentNode.removeChild(s)),i.test(e)||(s=u.getElementsByTagName("body")[0],s.parentNode.removeChild(s)),u.getElementsByTagName("html");break;case"head":if(m)return c=m(e).getElementsByTagName("head"),i.test(e)?c[0].parentNode.childNodes:c;break;case"body":if(m)return c=m(e).getElementsByTagName("body"),a.test(e)?c[0].parentNode.childNodes:c;break;default:if(d)return d(e);if(m)return m(e,"body").getElementsByTagName("body")[0].childNodes}return[]}},function(e,t,n){"use strict";function r(e){for(var t,n={},r=0,o=e.length;r<o;r++)t=e[r],n[t.name]=t.value;return n}function o(e,t,n){t=t||null;for(var a,i,u,s=[],c=0,d=e.length;c<d;c++){switch(a=e[c],u={next:null,prev:s[c-1]||null,parent:t},i=s[c-1],i&&(i.next=u),0!==a.nodeName.indexOf("#")&&(u.name=a.nodeName.toLowerCase(),u.attribs={},a.attributes&&a.attributes.length&&(u.attribs=r(a.attributes))),a.nodeType){case 1:"script"===u.name||"style"===u.name?u.type=u.name:u.type="tag",u.children=o(a.childNodes,u);break;case 3:u.type="text",u.data=a.nodeValue;break;case 8:u.type="comment",u.data=a.nodeValue}s.push(u)}return n&&(s.unshift({name:n.substring(0,n.indexOf(" ")).toLowerCase(),data:n,type:"directive",next:s[0]?s[0]:null,prev:null,parent:t}),s[1]&&(s[1].prev=s[0])),s}e.exports={formatAttributes:r,formatDOM:o}},function(e,t,n){"use strict";var r=n(0),o=n(1),a=o.formatDOM,i=/<(![a-zA-Z\s]+)>/;e.exports=function(e){if("string"!=typeof e)throw new TypeError("First argument must be a string.");if(!e)return[];var t,n=e.match(i);return n&&n[1]&&(t=n[1]),a(r(e),null,t)}}])}); |
@@ -45,3 +45,6 @@ 'use strict'; | ||
if (typeof document.implementation === 'object') { | ||
var doc = document.implementation.createHTMLDocument(); | ||
// title parameter is required in IE | ||
var doc = document.implementation.createHTMLDocument('title'); | ||
// remove the title | ||
doc.documentElement.innerHTML = ''; | ||
@@ -48,0 +51,0 @@ /** |
@@ -10,3 +10,3 @@ 'use strict'; | ||
/** | ||
* Parses HTML string to DOM nodes. | ||
* Parses HTML string to DOM nodes (server). | ||
* | ||
@@ -20,3 +20,3 @@ * This is the same method as `require('htmlparser2').parseDOM` | ||
*/ | ||
function parseDOM(html, options) { | ||
module.exports = function parseDOM(html, options) { | ||
if (typeof html !== 'string') { | ||
@@ -28,7 +28,2 @@ throw new TypeError('First argument must be a string.'); | ||
return handler.dom; | ||
} | ||
/** | ||
* Export HTML to DOM parser (server). | ||
*/ | ||
module.exports = parseDOM; | ||
}; |
{ | ||
"name": "html-dom-parser", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "An HTML to DOM parser that works on the server and client.", | ||
@@ -5,0 +5,0 @@ "author": "Mark <mark@remarkablemark.org>", |
@@ -12,3 +12,3 @@ # html-dom-parser | ||
## Installation | ||
## Install | ||
@@ -61,6 +61,4 @@ NPM: | ||
```sh | ||
$ git clone https://github.com/remarkablemark/html-dom-parser.git | ||
$ npm install | ||
$ npm test | ||
$ npm run lint | ||
$ npm test | ||
``` | ||
@@ -67,0 +65,0 @@ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
18511
312
67