This repository was archived by the owner on Oct 5, 2023. It is now read-only.
File tree 2 files changed +31
-3
lines changed
2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ function parse(xml) {
69
69
70
70
function tag ( ) {
71
71
debug ( 'tag %j' , xml ) ;
72
- var m = match ( / ^ < ( [ \w + : . ] + ) \s * / ) ;
72
+ var m = match ( / ^ < ( [ \w - : . ] + ) \s * / ) ;
73
73
if ( ! m ) return ;
74
74
75
75
// name
@@ -103,7 +103,7 @@ function parse(xml) {
103
103
}
104
104
105
105
// closing
106
- match ( / ^ < \/ [ \w : . ] + > \s * / ) ;
106
+ match ( / ^ < \/ [ \w - : . ] + > \s * / ) ;
107
107
108
108
return node ;
109
109
}
Original file line number Diff line number Diff line change @@ -231,4 +231,32 @@ it('should support tags with a dot', function () {
231
231
} ] ,
232
232
content : ""
233
233
} )
234
- } )
234
+ } )
235
+
236
+ it ( 'should support tags with hyphen' , function ( ) {
237
+ var node = parse (
238
+ '<root>' +
239
+ '<data-field1>val1</data-field1>' +
240
+ '<data-field2>val2</data-field2>' +
241
+ '</root>'
242
+ ) ;
243
+ node . root . should . eql ( {
244
+ name : 'root' ,
245
+ attributes : { } ,
246
+ content : '' ,
247
+ children : [
248
+ {
249
+ name : 'data-field1' ,
250
+ attributes : { } ,
251
+ children : [ ] ,
252
+ content : 'val1'
253
+ } ,
254
+ {
255
+ name : 'data-field2' ,
256
+ attributes : { } ,
257
+ children : [ ] ,
258
+ content : 'val2'
259
+ }
260
+ ]
261
+ } ) ;
262
+ } ) ;
You can’t perform that action at this time.
0 commit comments