@@ -916,57 +916,57 @@ private boolean inBodyEndTagAdoption(Token t, HtmlTreeBuilder tb) { |
916 | 916 | // JH - I think this means its index? Or do we need a linked list? |
917 | 917 | int bookmark = tb.positionOfElement(formatEl); |
918 | 918 |
|
919 | | - Element node = furthestBlock; // 11. Let node and lastNode be furthestBlock. |
920 | | - Element lastNode = furthestBlock; |
| 919 | + Element el = furthestBlock; // 11. Let node and lastNode be furthestBlock. |
| 920 | + Element lastEl = furthestBlock; |
921 | 921 | int inner = 0; // 12. Let innerLoopCounter be 0. |
922 | 922 |
|
923 | 923 | while (true) { // 13. While true: |
924 | 924 | inner++; // 1. Increment innerLoopCounter by 1. |
925 | 925 | // 2. Let node be the element immediately above node in the [stack of open elements], or if node is no longer in the [stack of open elements] , the element that was immediately above node in the [stack of open elements] before node was removed. |
926 | | - if (!tb.onStack(node)) { |
| 926 | + if (!tb.onStack(el)) { |
927 | 927 | // if node was removed from stack, use the element that was above it |
928 | | - node = node.parent(); // JH - is there a situation where it's not the parent? |
| 928 | + el = el.parent(); // JH - is there a situation where it's not the parent? |
929 | 929 | } else { |
930 | | - node = tb.aboveOnStack(node); |
| 930 | + el = tb.aboveOnStack(el); |
931 | 931 | } |
932 | | - if (node == null) { |
| 932 | + if (el == null) { |
933 | 933 | tb.error(this); // shouldn't be able to hit |
934 | 934 | break; |
935 | 935 | } |
936 | 936 | // 3. If node is formattingElement, then [break]. |
937 | | - if (node == formatEl) { |
| 937 | + if (el == formatEl) { |
938 | 938 | break; |
939 | 939 | } |
940 | 940 |
|
941 | 941 | // 4. If innerLoopCounter is greater than 3 and node is in the [list of active formatting elements], then remove node from the [list of active formatting elements]. |
942 | | - if (inner > 3 && tb.isInActiveFormattingElements(node)) { |
943 | | - tb.removeFromActiveFormattingElements(node); |
| 942 | + if (inner > 3 && tb.isInActiveFormattingElements(el)) { |
| 943 | + tb.removeFromActiveFormattingElements(el); |
944 | 944 | break; |
945 | 945 | } |
946 | 946 | // 5. If node is not in the [list of active formatting elements], then remove node from the [stack of open elements] and [continue]. |
947 | | - if (!tb.isInActiveFormattingElements(node)) { |
948 | | - tb.removeFromStack(node); |
| 947 | + if (!tb.isInActiveFormattingElements(el)) { |
| 948 | + tb.removeFromStack(el); |
949 | 949 | continue; |
950 | 950 | } |
951 | 951 |
|
952 | 952 | // 6. [Create an element for the token] for which the element node was created, in the [HTML namespace], with commonAncestor as the intended parent; replace the entry for node in the [list of active formatting elements] with an entry for the new element, replace the entry for node in the [stack of open elements] with an entry for the new element, and let node be the new element. |
953 | | - Element replacement = new Element(tb.tagFor(node.nodeName(), node.normalName(), tb.defaultNamespace(), ParseSettings.preserveCase), tb.getBaseUri()); |
954 | | - tb.replaceActiveFormattingElement(node, replacement); |
955 | | - tb.replaceOnStack(node, replacement); |
956 | | - node = replacement; |
| 953 | + Element replacement = new Element(tb.tagFor(el.nodeName(), el.normalName(), tb.defaultNamespace(), ParseSettings.preserveCase), tb.getBaseUri()); |
| 954 | + tb.replaceActiveFormattingElement(el, replacement); |
| 955 | + tb.replaceOnStack(el, replacement); |
| 956 | + el = replacement; |
957 | 957 |
|
958 | 958 | // 7. If lastNode is furthestBlock, then move the aforementioned bookmark to be immediately after the new node in the [list of active formatting elements]. |
959 | | - if (lastNode == furthestBlock) { |
960 | | - bookmark = tb.positionOfElement(node) + 1; |
| 959 | + if (lastEl == furthestBlock) { |
| 960 | + bookmark = tb.positionOfElement(el) + 1; |
961 | 961 | } |
962 | | - node.appendChild(lastNode); // 8. [Append] lastNode to node. |
963 | | - lastNode = node; // 9. Set lastNode to node. |
| 962 | + el.appendChild(lastEl); // 8. [Append] lastNode to node. |
| 963 | + lastEl = el; // 9. Set lastNode to node. |
964 | 964 | } // end inner loop # 13 |
965 | 965 |
|
966 | 966 | // 14. Insert whatever lastNode ended up being in the previous step at the [appropriate place for inserting a node], but using commonAncestor as the _override target_. |
967 | 967 | // todo - impl https://html.spec.whatwg.org/multipage/parsing.html#appropriate-place-for-inserting-a-node fostering |
968 | 968 | // just use commonAncestor as target: |
969 | | - commonAncestor.appendChild(lastNode); |
| 969 | + commonAncestor.appendChild(lastEl); |
970 | 970 | // 15. [Create an element for the token] for which formattingElement was created, in the [HTML namespace], with furthestBlock as the intended parent. |
971 | 971 | Element adoptor = new Element(formatEl.tag(), tb.getBaseUri()); |
972 | 972 | adoptor.attributes().addAll(formatEl.attributes()); // also attributes |
|