1717const { expect} = require ( 'chai' ) ;
1818const { JSDOM } = require ( 'jsdom' ) ;
1919
20-
21- const parseHtmlChunk = htmlStr => {
22- const { body} = ( new JSDOM ( htmlStr ) ) . window . document ;
20+ const parseHtmlChunk = ( htmlStr ) => {
21+ const { body} = new JSDOM ( htmlStr ) . window . document ;
2322 expect ( body . children ) . to . have . length ( 1 ) ;
2423 return body . firstElementChild ;
2524} ;
2625
27-
28- const boundAttrRe = attr =>
26+ const boundAttrRe = ( attr ) =>
2927 new RegExp ( `\\[${ attr } \\]=(("[^"]+")|('[^']+')|([^\\s\\>]+))` ) ;
3028
31-
3229// JSDom doesn't parse attributes whose names don't follow the spec, so
3330// our only way to test [attr] values is via regex.
3431const getBoundAttr = ( { outerHTML} , attr ) => {
@@ -37,13 +34,11 @@ const getBoundAttr = ({outerHTML}, attr) => {
3734 return ;
3835 }
3936 const [ , valuePart ] = match ;
40- if ( valuePart . charAt ( 0 ) == '"' ||
41- valuePart . charAt ( 0 ) == '\'' ) {
37+ if ( valuePart . charAt ( 0 ) == '"' || valuePart . charAt ( 0 ) == "'" ) {
4238 return valuePart . substring ( 1 , valuePart . length - 1 ) ;
4339 }
4440 return valuePart ;
45- }
46-
41+ } ;
4742
4843const expectValidAmphtml = ( validator , string ) => {
4944 const { errors : errorsAndWarnings , status} = validator . validateString ( string ) ;
@@ -55,7 +50,6 @@ const expectValidAmphtml = (validator, string) => {
5550 expect ( status ) . to . equal ( 'PASS' ) ;
5651} ;
5752
58-
5953module . exports = {
6054 expectValidAmphtml,
6155 getBoundAttr,
0 commit comments