build(platform-server): update parse5 to v3 (#14538)

This commit is contained in:
Victor Berchet 2017-02-23 21:14:04 -08:00 committed by Igor Minar
parent 39f56fafdd
commit 01907bafb0
5 changed files with 28 additions and 14 deletions

View File

@ -15,7 +15,7 @@
"@angular/platform-browser": "0.0.0-PLACEHOLDER"
},
"dependencies": {
"parse5": "^2.2.1",
"parse5": "^3.0.1",
"xhr2": "^0.1.4"
},
"repository": {

View File

@ -79,6 +79,7 @@ export class Parse5DomAdapter extends DomAdapter {
get attrToPropMap() { return _attrToPropMap; }
querySelector(el: any, selector: string): any { return this.querySelectorAll(el, selector)[0]; }
querySelectorAll(el: any, selector: string): any[] {
const res: any[] = [];
const _recursive = (result: any, node: any, selector: any, matcher: any) => {
@ -372,7 +373,8 @@ export class Parse5DomAdapter extends DomAdapter {
classList(element: any): string[] {
let classAttrValue: any = null;
const attributes = element.attribs;
if (attributes && attributes.hasOwnProperty('class')) {
if (attributes && attributes['class'] != null) {
classAttrValue = attributes['class'];
}
return classAttrValue ? classAttrValue.trim().split(/\s+/g) : [];
@ -404,7 +406,7 @@ export class Parse5DomAdapter extends DomAdapter {
_readStyleAttribute(element: any) {
const styleMap = {};
const attributes = element.attribs;
if (attributes && attributes.hasOwnProperty('style')) {
if (attributes && attributes['style'] != null) {
const styleAttrValue = attributes['style'];
const styleList = styleAttrValue.split(/;+/g);
for (let i = 0; i < styleList.length; i++) {
@ -448,13 +450,11 @@ export class Parse5DomAdapter extends DomAdapter {
return res;
}
hasAttribute(element: any, attribute: string): boolean {
return element.attribs && element.attribs.hasOwnProperty(attribute);
return element.attribs && element.attribs[attribute] != null;
}
hasAttributeNS(element: any, ns: string, attribute: string): boolean { throw 'not implemented'; }
getAttribute(element: any, attribute: string): string {
return element.attribs && element.attribs.hasOwnProperty(attribute) ?
element.attribs[attribute] :
null;
return this.hasAttribute(element, attribute) ? element.attribs[attribute] : null;
}
getAttributeNS(element: any, ns: string, attribute: string): string { throw 'not implemented'; }
setAttribute(element: any, attribute: string, value: string) {

View File

@ -5567,8 +5567,14 @@
"dev": true
},
"parse5": {
"version": "2.2.1",
"dev": true
"version": "3.0.1",
"dev": true,
"dependencies": {
"@types/node": {
"version": "6.0.63",
"dev": true
}
}
},
"parsejson": {
"version": "0.0.1",

16
npm-shrinkwrap.json generated
View File

@ -8137,10 +8137,18 @@
"dev": true
},
"parse5": {
"version": "2.2.1",
"from": "parse5@2.2.1",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-2.2.1.tgz",
"dev": true
"version": "3.0.1",
"from": "parse5@3.0.1",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-3.0.1.tgz",
"dev": true,
"dependencies": {
"@types/node": {
"version": "6.0.63",
"from": "@types/node@>=6.0.46 <7.0.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-6.0.63.tgz",
"dev": true
}
}
},
"parsejson": {
"version": "0.0.1",

View File

@ -82,7 +82,7 @@
"minimist": "^1.2.0",
"nan": "^2.4.0",
"node-uuid": "1.4.x",
"parse5": "^2.2.1",
"parse5": "^3.0.1",
"protractor": "^4.0.11",
"react": "^0.14.0",
"rewire": "^2.3.3",