File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ module.exports = function parse(html, options) {
3636 inComponent = true ;
3737 }
3838
39- if ( ! inComponent && nextChar && nextChar !== '<' ) {
39+ if ( ! current . voidElement && ! inComponent && nextChar && nextChar !== '<' ) {
4040 current . children . push ( {
4141 type : 'text' ,
4242 content : html . slice ( start , html . indexOf ( '<' , start ) )
Original file line number Diff line number Diff line change @@ -270,6 +270,28 @@ test('parse', function (t) {
270270 ]
271271 } ] , 'should handle registered void tags if self-closing' ) ;
272272
273+
274+ html = '<div> 9 <input type="text"/> 10 </div>' ;
275+ parsed = HTML . parse ( html ) ;
276+ t . deepEqual ( parsed , [ {
277+ type : 'tag' ,
278+ name : 'div' ,
279+ attrs : { } ,
280+ voidElement : false ,
281+ children : [
282+ { type : 'text' , content : ' 9 ' } ,
283+ {
284+ type : 'tag' ,
285+ name : 'input' ,
286+ attrs : {
287+ type : 'text'
288+ } ,
289+ children : [ ] ,
290+ voidElement : true ,
291+ } ,
292+ { type : 'text' , content : ' 10 ' } ,
293+ ]
294+ } ] , 'should not give voidElements children' ) ;
273295 t . end ( ) ;
274296} ) ;
275297
You can’t perform that action at this time.
0 commit comments