@qualweb/html-techniques
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -7,3 +7,3 @@ 'use strict'; | ||
const htmlparser_to_html_1 = __importDefault(require("htmlparser-to-html")); | ||
const lodash_1 = __importDefault(require("lodash")); | ||
const clone_1 = __importDefault(require("lodash/clone")); | ||
const stew = new (require('stew-select')).Stew(); | ||
@@ -43,3 +43,3 @@ function getSelfLocationInParent(element) { | ||
} | ||
selector += lodash_1.default.join(parents, ' > '); | ||
selector += parents.join(' > '); | ||
selector += ' > ' + getSelfLocationInParent(element); | ||
@@ -53,5 +53,7 @@ return selector; | ||
} | ||
let codeElement = lodash_1.default.clone(element); | ||
let codeElement = clone_1.default(element); | ||
if (codeElement.attribs) { | ||
delete codeElement.attribs['computed-style']; | ||
delete codeElement.attribs['computed-style-after']; | ||
delete codeElement.attribs['computed-style-before']; | ||
delete codeElement.attribs['w-scrollx']; | ||
@@ -61,4 +63,8 @@ delete codeElement.attribs['w-scrolly']; | ||
delete codeElement.attribs['b-bottom']; | ||
delete codeElement.attribs['window-inner-height']; | ||
delete codeElement.attribs['window-inner-width']; | ||
delete codeElement.attribs['document-client-height']; | ||
delete codeElement.attribs['document-client-width']; | ||
} | ||
if (codeElement.attribs && codeElement.attribs.id && lodash_1.default.startsWith(codeElement.attribs.id, 'qualweb_generated_id')) { | ||
if (codeElement.attribs && codeElement.attribs.id && codeElement.attribs.id.startsWith('qw-generated-id')) { | ||
delete codeElement.attribs.id; | ||
@@ -68,7 +74,7 @@ } | ||
if (withText) { | ||
let children = lodash_1.default.clone(codeElement.children); | ||
let children = clone_1.default(codeElement.children); | ||
codeElement.children = []; | ||
for (let child of children || []) { | ||
if (child.type === 'text') { | ||
codeElement.children.push(lodash_1.default.clone(child)); | ||
codeElement.children.push(clone_1.default(child)); | ||
} | ||
@@ -162,4 +168,4 @@ } | ||
if (element.attribs['computed-style'] !== undefined) { | ||
displayNone = lodash_1.default.trim(getComputedStylesAttribute(element, 'computed-style', '^ display:')) === 'none'; | ||
let visibilityATT = lodash_1.default.trim(getComputedStylesAttribute(element, 'computed-style', '^ visibility:')); | ||
displayNone = getComputedStylesAttribute(element, 'computed-style', '^ display:').trim() === 'none'; | ||
let visibilityATT = getComputedStylesAttribute(element, 'computed-style', '^ visibility:').trim(); | ||
visibility = visibilityATT === 'collapse' || visibilityATT === 'hidden'; | ||
@@ -166,0 +172,0 @@ } |
{ | ||
"name": "@qualweb/html-techniques", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Implementation of the WCAG 2.1 html techniques", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -5,3 +5,3 @@ 'use strict'; | ||
import html from 'htmlparser-to-html'; | ||
import _ from 'lodash'; | ||
import clone from 'lodash/clone'; | ||
@@ -51,3 +51,3 @@ const stew = new (require('stew-select')).Stew(); | ||
selector += _.join(parents, ' > '); | ||
selector += parents.join(' > '); | ||
selector += ' > ' + getSelfLocationInParent(element); | ||
@@ -64,6 +64,8 @@ | ||
let codeElement: DomElement = _.clone(element); | ||
let codeElement: DomElement = clone(element); | ||
if (codeElement.attribs) { | ||
delete codeElement.attribs['computed-style']; | ||
delete codeElement.attribs['computed-style-after']; | ||
delete codeElement.attribs['computed-style-before']; | ||
delete codeElement.attribs['w-scrollx']; | ||
@@ -73,5 +75,9 @@ delete codeElement.attribs['w-scrolly']; | ||
delete codeElement.attribs['b-bottom']; | ||
delete codeElement.attribs['window-inner-height']; | ||
delete codeElement.attribs['window-inner-width']; | ||
delete codeElement.attribs['document-client-height']; | ||
delete codeElement.attribs['document-client-width']; | ||
} | ||
if (codeElement.attribs && codeElement.attribs.id && _.startsWith(codeElement.attribs.id, 'qualweb_generated_id')) { | ||
if (codeElement.attribs && codeElement.attribs.id && codeElement.attribs.id.startsWith('qw-generated-id')) { | ||
delete codeElement.attribs.id; | ||
@@ -82,3 +88,3 @@ } | ||
if (withText) { | ||
let children = _.clone(codeElement.children); | ||
let children = clone(codeElement.children); | ||
codeElement.children = []; | ||
@@ -88,3 +94,3 @@ | ||
if (child.type === 'text') { | ||
codeElement.children.push(_.clone(child)); | ||
codeElement.children.push(clone(child)); | ||
} | ||
@@ -183,4 +189,4 @@ } | ||
if (element.attribs['computed-style'] !== undefined) { | ||
displayNone = _.trim(getComputedStylesAttribute(element, 'computed-style', '^ display:')) === 'none'; | ||
let visibilityATT = _.trim(getComputedStylesAttribute(element, 'computed-style', '^ visibility:')); | ||
displayNone = getComputedStylesAttribute(element, 'computed-style', '^ display:').trim() === 'none'; | ||
let visibilityATT = getComputedStylesAttribute(element, 'computed-style', '^ visibility:').trim(); | ||
visibility = visibilityATT === 'collapse' || visibilityATT === 'hidden'; | ||
@@ -187,0 +193,0 @@ } |
@@ -20,3 +20,3 @@ const { | ||
}); | ||
/*it('test stew select invalid predicate', async function() { | ||
it('test result html code without custom attributes', async function() { | ||
this.timeout(20 * 1000); | ||
@@ -26,5 +26,5 @@ const { source, processed } = await getDom('https://ciencias.ulisboa.pt'); | ||
let report = await executeHTMLT('https://ciencias.ulisboa.pt', source.html.parsed, processed.html.parsed); | ||
console.warn(JSON.stringify(report, null, 2)); | ||
expect(report.type).to.be.equal('html-techniques'); | ||
});*/ | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
297197
8002