@@ -17,25 +17,24 @@ for (var i = 0; i < js.length; i++) {
1717 var attr = js [ i ] . attributes [ j ] ;
1818 if ( / ^ d a t a - i s s o - / . test ( attr . name ) ) {
1919
20+ // Normalize underscores to dashes so that language-specific
21+ // strings can be caught better later on, e.g.
22+ // data-isso-postbox-text-text-PT_BR becomes postbox-text-text-pt-br.
23+ // Also note that attr.name only gives lowercase strings as per HTML
24+ // spec, e.g. data-isso-FOO-Bar becomes foo-bar, but since the test
25+ // environment's jest-environment-jsdom seemingly does not follow
26+ // that convention, convert to lowercase here anyway.
27+ const attrName = attr . name . substring ( 10 )
28+ . replace ( / _ / g, '-' )
29+ . toLowerCase ( )
30+
2031 // Replace escaped newline characters in the attribute value with actual newline characters
2132 const attrValue = attr . value . replace ( / \\ n / g, '\n' ) ;
2233
2334 try {
24- // Normalize underscores to dashes so that language-specific
25- // strings can be caught better later on,
26- // e.g. data-isso-postbox-text-text-PT_BR becomes
27- // postbox-text-text-pt-br.
28- // Also note that attr.name only gives lowercase strings as per
29- // HTML spec, e.g. data-isso-FOO-Bar becomes foo-bar, but since
30- // the test environment's jest-environment-jsdom seemingly does
31- // not follow that convention, convert to lowercase here anyway.
32- config [ attr . name . substring ( 10 )
33- . replace ( / _ / g, '-' )
34- . toLowerCase ( ) ] = JSON . parse ( attrValue ) ;
35+ config [ attrName ] = JSON . parse ( attrValue ) ;
3536 } catch ( ex ) {
36- config [ attr . name . substring ( 10 )
37- . replace ( / _ / g, '-' )
38- . toLowerCase ( ) ] = attrValue ;
37+ config [ attrName ] = attrValue ;
3938 }
4039 }
4140 }
0 commit comments