File tree 4 files changed +45
-5
lines changed
4 files changed +45
-5
lines changed Original file line number Diff line number Diff line change @@ -456,9 +456,9 @@ export default class HTMLElement extends Node {
456
456
this . childNodes . length = o ;
457
457
458
458
// remove whitespace between attributes
459
- const attrs = Object . keys ( this . rawAttributes ) . map ( ( key ) => {
459
+ const attrs = Object . keys ( this . rawAttributes ) . map ( ( key ) => {
460
460
const val = this . rawAttributes [ key ] ;
461
- return `${ key } =${ JSON . stringify ( val ) } ` ;
461
+ return `${ key } =${ JSON . stringify ( val ) } ` ;
462
462
} ) . join ( ' ' ) ;
463
463
this . rawAttrs = attrs ;
464
464
delete this . _rawAttrs ;
@@ -959,8 +959,10 @@ export default class HTMLElement extends Node {
959
959
}
960
960
}
961
961
962
+ // #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
962
963
// https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
963
- const kMarkupPattern = / < ! - - [ \s \S ] * ?- - > | < ( \/ ? ) ( [ a - z A - Z ] [ - . : 0 - 9 _ a - z A - Z ] * ) ( (?: \s + [ ^ > ] * ?(?: (?: ' [ ^ ' ] * ' ) | (?: " [ ^ " ] * " ) ) ? ) * ) \s * ( \/ ? ) > / g;
964
+ const kMarkupPattern = / < ! - - [ \s \S ] * ?- - > | < ( \/ ? ) ( [ a - z A - Z ] [ - . : 0 - 9 _ a - z A - Z @ \xB7 \xC0 - \xD6 \xD8 - \xF6 \u00F8 - \u03A1 \u03A3 - \u03D9 \u03DB - \u03EF \u03F7 - \u03FF \u0400 - \u04FF \u0500 - \u052F \u1D00 - \u1D2B \u1D6B - \u1D77 \u1D79 - \u1D9A \u1E00 - \u1E9B \u1F00 - \u1F15 \u1F18 - \u1F1D \u1F20 - \u1F45 \u1F48 - \u1F4D \u1F50 - \u1F57 \u1F59 \u1F5B \u1F5D \u1F5F - \u1F7D \u1F80 - \u1FB4 \u1FB6 - \u1FBC \u1FBE \u1FC2 - \u1FC4 \u1FC6 - \u1FCC \u1FD0 - \u1FD3 \u1FD6 - \u1FDB \u1FE0 - \u1FEC \u1FF2 - \u1FF4 \u1FF6 - \u1FFC \u2126 \u212A - \u212B \u2132 \u214E \u2160 - \u2188 \u2C60 - \u2C7F \uA722 - \uA787 \uA78B - \uA78E \uA790 - \uA7AD \uA7B0 - \uA7B7 \uA7F7 - \uA7FF \uAB30 - \uAB5A \uAB5C - \uAB5F \uAB64 - \uAB65 \uFB00 - \uFB06 \uFB13 - \uFB17 \uFF21 - \uFF3A \uFF41 - \uFF5A \x37 F - \u1FFF \u200C - \u200D \u203F - \u2040 \u2070 - \u218F \u2C00 - \u2FEF \u3001 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFFD ] * ) ( (?: \s + [ ^ > ] * ?(?: (?: ' [ ^ ' ] * ' ) | (?: " [ ^ " ] * " ) ) ? ) * ) \s * ( \/ ? ) > / gu;
965
+ // const kMarkupPattern = /<!--[\s\S]*?-->|<(\/?)([a-zA-Z][-.:0-9_a-zA-Z]*)((?:\s+[^>]*?(?:(?:'[^']*')|(?:"[^"]*"))?)*)\s*(\/?)>/g;
964
966
const kAttributePattern = / (?: ^ | \s ) ( i d | c l a s s ) \s * = \s * ( (?: ' [ ^ ' ] * ' ) | (?: " [ ^ " ] * " ) | \S + ) / gi;
965
967
const kElementsClosedByOpening = {
966
968
li : { li : true , LI : true } ,
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ describe.skip('issue 268', function () {
25
25
const html = `<a href="#" 2'>x</a><a href="#" 2'>x</a>` ;
26
26
const root = parse ( html ) ;
27
27
const a = root . querySelector ( "a" ) ;
28
- console . error ( 'sss' , a . attributes ) ;
28
+ console . error ( 'sss' , a . attributes ) ;
29
29
a . toString ( ) . should . eql ( '<a href="#" 2">x</a>' ) ;
30
30
// for (let tr of root.querySelectorAll("#mytable tr.myrow")) {
31
31
// console.log('xxx',tr.querySelectorAll(":scope > td").map(e => e.innerText));
Original file line number Diff line number Diff line change
1
+ const { parse } = require ( '@test/test-target' ) ;
2
+
3
+ describe ( 'issue 277' , function ( ) {
4
+ it ( 'custom tag name' , function ( ) {
5
+ const html = `<!DOCTYPE html>
6
+ <html lang="en">
7
+ <head>
8
+ <title>test</title>
9
+ </head>
10
+ <body>
11
+ <template>
12
+ <h@1>Smile!</h@1>
13
+ </template>
14
+ </body>
15
+ </html>` ;
16
+ const root = parse ( html ) ;
17
+ const t = root . querySelector ( 'template' ) ;
18
+ const el = t . childNodes [ 1 ] ;
19
+ el . toString ( ) . should . eql ( '<h@1>Smile!</h@1>' ) ;
20
+ } ) ;
21
+ it ( 'unicode tag name' , function ( ) {
22
+ const html = `<!DOCTYPE html>
23
+ <html lang="en">
24
+ <head>
25
+ <title>test</title>
26
+ </head>
27
+ <body>
28
+ <template>
29
+ <h测试اختبار>Smile!</h测试اختبار>
30
+ </template>
31
+ </body>
32
+ </html>` ;
33
+ const root = parse ( html ) ;
34
+ const t = root . querySelector ( 'template' ) ;
35
+ const el = t . childNodes [ 1 ] ;
36
+ el . toString ( ) . should . eql ( '<h测试اختبار>Smile!</h测试اختبار>' ) ;
37
+ } ) ;
38
+ } ) ;
Original file line number Diff line number Diff line change 4
4
],
5
5
"compilerOptions" : {
6
6
"module" : " commonjs" ,
7
- "target" : " es5 " ,
7
+ "target" : " es6 " ,
8
8
"noImplicitAny" : true ,
9
9
"sourceMap" : false ,
10
10
"emitDecoratorMetadata" : true ,
You can’t perform that action at this time.
0 commit comments