diff --git a/modules/@angular/platform-server/package.json b/modules/@angular/platform-server/package.json index 61f8e6f960..0e0fd87996 100644 --- a/modules/@angular/platform-server/package.json +++ b/modules/@angular/platform-server/package.json @@ -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": { diff --git a/modules/@angular/platform-server/src/parse5_adapter.ts b/modules/@angular/platform-server/src/parse5_adapter.ts index 151bb93367..383e1cc532 100644 --- a/modules/@angular/platform-server/src/parse5_adapter.ts +++ b/modules/@angular/platform-server/src/parse5_adapter.ts @@ -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) { diff --git a/npm-shrinkwrap.clean.json b/npm-shrinkwrap.clean.json index 607c87eb37..3c84725fb1 100644 --- a/npm-shrinkwrap.clean.json +++ b/npm-shrinkwrap.clean.json @@ -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", diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 2a4c3af528..5cc1acf1fe 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -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", diff --git a/package.json b/package.json index 645e560847..befc35825b 100644 --- a/package.json +++ b/package.json @@ -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",