浏览代码

[lexer] don't lose `in_open` status

see #8165
Simon Krajewski 6 年之前
父节点
当前提交
67698ab5ad
共有 2 个文件被更改,包括 6 次插入2 次删除
  1. 2 2
      src/syntax/lexer.ml
  2. 4 0
      tests/unit/src/unitstd/InlineXml.unit.hx

+ 2 - 2
src/syntax/lexer.ml

@@ -563,13 +563,13 @@ and not_xml ctx depth in_open =
 			if depth = 0 then lexeme_end lexbuf
 			if depth = 0 then lexeme_end lexbuf
 			else not_xml ctx (depth - 1) false
 			else not_xml ctx (depth - 1) false
 		end else
 		end else
-			not_xml ctx depth false
+			not_xml ctx depth in_open
 	(* opening tag *)
 	(* opening tag *)
 	| '<',xml_name ->
 	| '<',xml_name ->
 		let s = lexeme lexbuf in
 		let s = lexeme lexbuf in
 		Buffer.add_string buf s;
 		Buffer.add_string buf s;
 		(* If it matches our document open tag, increase depth and set in_open to true. *)
 		(* If it matches our document open tag, increase depth and set in_open to true. *)
-		let depth,in_open = if s = ctx.open_tag then depth + 1,true else depth,false in
+		let depth,in_open = if s = ctx.open_tag then depth + 1,true else depth,in_open in
 		not_xml ctx depth in_open
 		not_xml ctx depth in_open
 	(* /> *)
 	(* /> *)
 	| '/','>' ->
 	| '/','>' ->

+ 4 - 0
tests/unit/src/unitstd/InlineXml.unit.hx

@@ -23,6 +23,10 @@ unit.HelperMacros.pipeMarkupLiteral(<foo.Bar_barf3-gnieh:blargh></foo.Bar_barf3-
 unit.HelperMacros.pipeMarkupLiteral(<></>) == "<></>";
 unit.HelperMacros.pipeMarkupLiteral(<></>) == "<></>";
 unit.HelperMacros.pipeMarkupLiteral(<>abc</>) == "<>abc</>";
 unit.HelperMacros.pipeMarkupLiteral(<>abc</>) == "<>abc</>";
 
 
+// more tags in open
+
+unit.HelperMacros.pipeMarkupLiteral(<some-component header=${unit.HelperMacros.pipeMarkupLiteral(<div>Test</div>)} />) == "<some-component header=<div>Test</div> />";
+
 // No check for string literal balancing
 // No check for string literal balancing
 unit.HelperMacros.pipeMarkupLiteral(<xml a=" </xml>) == "<xml a=\" </xml>";
 unit.HelperMacros.pipeMarkupLiteral(<xml a=" </xml>) == "<xml a=\" </xml>";
 unit.HelperMacros.pipeMarkupLiteral(<xml a=' </xml>) == "<xml a=' </xml>";
 unit.HelperMacros.pipeMarkupLiteral(<xml a=' </xml>) == "<xml a=' </xml>";