Skip to content

Commit a8247f1

Browse files
committed
simplify code and one more test
1 parent c2c37e7 commit a8247f1

6 files changed

Lines changed: 39 additions & 22 deletions

File tree

src/main/java/org/htmlunit/cyberneko/HTMLTagBalancer.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -858,22 +858,6 @@ else if (!fTemplateFragment && elementCode == HTMLElements.SELECT) {
858858
fOpenedSelect = true;
859859
}
860860

861-
// if block element, save immediate parent formatting elements
862-
int depth = 0;
863-
if (element.flags == 0) {
864-
final int length = fElementStack.length;
865-
fFormattingStack.length = 0;
866-
for (int i = length - 1; i >= 0; i--) {
867-
final Info info = fElementStack.data[i];
868-
if (!info.element.isFormatting()) {
869-
break;
870-
}
871-
fFormattingStack.push(info);
872-
endElement(info.qname, synthesizedAugs());
873-
}
874-
depth = fFormattingStack.length;
875-
}
876-
877861
// close previous elements
878862
// all elements close a <script>
879863
// in head, no element has children
@@ -949,12 +933,6 @@ else if (!fTemplateFragment && elementCode == HTMLElements.SELECT) {
949933
}
950934
}
951935

952-
// re-open formatting elements
953-
for (int i = 0; i < depth; i++) {
954-
final Info info = fFormattingStack.pop();
955-
forceStartElement(info.qname, info.attributes, synthesizedAugs());
956-
}
957-
958936
if (elementCode == HTMLElements.BODY) {
959937
lostText_.refeed(this);
960938
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<b>bold text before<div>a block element</div>bold text after</b>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
(html
2+
(head
3+
)head
4+
(body
5+
(b
6+
"bold text before
7+
(div
8+
"a block element
9+
)div
10+
"bold text after
11+
)b
12+
)body
13+
)html
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
(b
2+
"bold text before
3+
(div
4+
"a block element
5+
)div
6+
"bold text after
7+
)b
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<html><head></head><body><b>bold text before<div>a block element</div>bold text after</b></body></html>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
startDocument [(1,1,0) (1,1,0) false]
2+
startElement (localpart="html",rawname="html",uri="http://www.w3.org/1999/xhtml") [(-1,-1,-1) (-1,-1,-1) true]
3+
startElement (localpart="head",rawname="head",uri="http://www.w3.org/1999/xhtml") [(-1,-1,-1) (-1,-1,-1) true]
4+
endElement (localpart="head",rawname="head",uri="http://www.w3.org/1999/xhtml") [(-1,-1,-1) (-1,-1,-1) true]
5+
startElement (localpart="body",rawname="body",uri="http://www.w3.org/1999/xhtml") [(-1,-1,-1) (-1,-1,-1) true]
6+
startElement (localpart="b",rawname="b") [(1,1,0) (1,4,3) false]
7+
characters 'bold text before'[(1,4,3) (1,20,19) false]
8+
startElement (localpart="div",rawname="div") [(1,20,19) (1,25,24) false]
9+
characters 'a block element'[(1,25,24) (1,40,39) false]
10+
endElement (localpart="div",rawname="div") [(1,40,39) (1,46,45) false]
11+
characters 'bold text after'[(1,46,45) (1,61,60) false]
12+
endElement (localpart="b",rawname="b") [(1,61,60) (1,65,64) false]
13+
characters '
14+
'[(1,65,64) (2,1,65) false]
15+
endElement (localpart="body",rawname="body",uri="http://www.w3.org/1999/xhtml") [(-1,-1,-1) (-1,-1,-1) true]
16+
endElement (localpart="html",rawname="html",uri="http://www.w3.org/1999/xhtml") [(-1,-1,-1) (-1,-1,-1) true]
17+
endDocument [(2,1,65) (2,1,65) false]

0 commit comments

Comments
 (0)