1. Stephen McKamey
  2. duel

Commits

Stephen McKamey  committed 2f5e096

bug fix for suspendMode leaking when written as void tag

  • Participants
  • Parent commits 9f8103a
  • Branches default

Comments (0)

Files changed (2)

File duel-compiler/src/main/java/org/duelengine/duel/parsing/DuelLexer.java

View file
 						switch (this.ch) {
 							case DuelGrammar.OP_ELEM_CLOSE:
 								if (this.nextChar() == DuelGrammar.OP_ELEM_END) {
+									// need to end suspendMode for void tags
+									this.suspendMode = false;
 									// immediately close the last tag
 									return (this.token = DuelToken.elemEnd(this.lastTag, this.token_index, this.token_line, this.token_column));
 								}

File duel-compiler/src/test/java/org/duelengine/duel/parsing/DuelLexerTest.java

View file
 	}
 
 	@Test
+	public void scriptVoidTest() {
+
+		String input =
+			"<div class='content'>\r\n"+
+			"\t<script type='text/javascript' src='foo.js' />\r\n"+
+			"\t<script type='text/javascript' src='bar.js' />\r\n"+
+			"\t<script type='text/javascript'>go();</script>\r\n"+
+			"</div>";
+
+		Object[] expected = {
+				DuelToken.elemBegin("div"),
+				DuelToken.attrName("class"),
+				DuelToken.attrValue("content"),
+				DuelToken.literal("\n\t"),
+				DuelToken.elemBegin("script"),
+				DuelToken.attrName("type"),
+				DuelToken.attrValue("text/javascript"),
+				DuelToken.attrName("src"),
+				DuelToken.attrValue("foo.js"),
+				DuelToken.elemEnd("script"),
+				DuelToken.literal("\n\t"),
+				DuelToken.elemBegin("script"),
+				DuelToken.attrName("type"),
+				DuelToken.attrValue("text/javascript"),
+				DuelToken.attrName("src"),
+				DuelToken.attrValue("bar.js"),
+				DuelToken.elemEnd("script"),
+				DuelToken.literal("\n\t"),
+				DuelToken.elemBegin("script"),
+				DuelToken.attrName("type"),
+				DuelToken.attrValue("text/javascript"),
+				DuelToken.literal("go();"),
+				DuelToken.elemEnd("script"),
+				DuelToken.literal("\n"),
+				DuelToken.elemEnd("div")
+			};
+
+		Object[] actual = new DuelLexer(input).toList().toArray();
+
+		assertArrayEquals(expected, actual);
+	}
+
+	@Test
 	public void scriptUnwrapMarkupTest() {
 
 		String input =
 		assertArrayEquals(expected, actual);
 	}
 
-//	private void dumpLists(Object[] expected, Object[] actual) {
-//
-//		for (Object token : expected) {
-//			System.out.println(token.toString());
-//		}
-//
-//		for (Object token : actual) {
-//			System.err.println(token.toString());
-//		}
-//	}
+	@SuppressWarnings("unused")
+	private void dumpLists(Object[] expected, Object[] actual) {
+
+		for (Object token : expected) {
+			System.out.println(token.toString());
+		}
+		System.out.flush();
+
+		for (Object token : actual) {
+			System.err.println(token.toString());
+		}
+	}
 }