Fixes no rel noopener when properties of anchor element cannot be resolved anymore (#1818)

* Fixes no rel noopener when anchor element is not available anymore. #1802
* Change rellnoopener to getAttribute('href')
This commit is contained in:
Ward Peeters 2017-03-07 00:58:29 +01:00 коммит произвёл Paul Irish
Родитель 07b8d3f16f
Коммит 91ad83a37c
4 изменённых файлов: 7 добавлений и 4 удалений

Просмотреть файл

@ -39,9 +39,11 @@ module.exports = [
}, },
'external-anchors-use-rel-noopener': { 'external-anchors-use-rel-noopener': {
score: false, score: false,
debugString: 'Lighthouse was unable to determine the destination of some anchor tags. ' +
'If they are not used as hyperlinks, consider removing the _blank target.',
extendedInfo: { extendedInfo: {
value: { value: {
length: 2 length: 3
} }
} }
}, },

Просмотреть файл

@ -494,7 +494,7 @@ class Driver {
* @return {!Promise<string>} The property value, or null, if property not found * @return {!Promise<string>} The property value, or null, if property not found
*/ */
getObjectProperty(objectId, propName) { getObjectProperty(objectId, propName) {
return new Promise((resolve, reject) => { return new Promise(resolve => {
this.sendCommand('Runtime.getProperties', { this.sendCommand('Runtime.getProperties', {
objectId, objectId,
accessorPropertiesOnly: true, accessorPropertiesOnly: true,
@ -508,7 +508,7 @@ class Driver {
if (propertyForName) { if (propertyForName) {
resolve(propertyForName.value.value); resolve(propertyForName.value.value);
} else { } else {
reject(null); resolve(null);
} }
}); });
}); });

Просмотреть файл

@ -29,7 +29,7 @@ class AnchorsWithNoRelNoopener extends Gatherer {
.then(failingNodeList => { .then(failingNodeList => {
const failingNodes = failingNodeList.map(node => { const failingNodes = failingNodeList.map(node => {
return Promise.all([ return Promise.all([
node.getProperty('href'), node.getAttribute('href'),
node.getAttribute('rel'), node.getAttribute('rel'),
node.getAttribute('target') node.getAttribute('target')
]); ]);

Просмотреть файл

@ -43,6 +43,7 @@ class Element {
if (attrIndex === -1) { if (attrIndex === -1) {
return null; return null;
} }
return resp.attributes[attrIndex + 1]; return resp.attributes[attrIndex + 1];
}); });
} }