}
function unwrapBr(br: HTMLElement): void {
- if (br.previousSibling || br.nextSibling) {
- return;
- }
+ for (;;) {
+ if (br.previousSibling || br.nextSibling) {
+ return;
+ }
- const parent = br.parentElement!;
- switch (parent.tagName) {
- case "B":
- case "DEL":
- case "EM":
- case "I":
- case "STRONG":
- case "SUB":
- case "SUP":
- case "SPAN":
- case "U":
- parent.insertAdjacentElement("afterend", br);
- parent.remove();
-
- unwrapBr(br);
- break;
+ const parent = br.parentElement!;
+ switch (parent.tagName) {
+ case "B":
+ case "DEL":
+ case "EM":
+ case "I":
+ case "STRONG":
+ case "SUB":
+ case "SUP":
+ case "SPAN":
+ case "U":
+ parent.insertAdjacentElement("afterend", br);
+ parent.remove();
+ break;
+
+ default:
+ return;
+ }
}
}
});
}
function unwrapBr(br) {
- if (br.previousSibling || br.nextSibling) {
- return;
- }
- const parent = br.parentElement;
- switch (parent.tagName) {
- case "B":
- case "DEL":
- case "EM":
- case "I":
- case "STRONG":
- case "SUB":
- case "SUP":
- case "SPAN":
- case "U":
- parent.insertAdjacentElement("afterend", br);
- parent.remove();
- unwrapBr(br);
- break;
+ for (;;) {
+ if (br.previousSibling || br.nextSibling) {
+ return;
+ }
+ const parent = br.parentElement;
+ switch (parent.tagName) {
+ case "B":
+ case "DEL":
+ case "EM":
+ case "I":
+ case "STRONG":
+ case "SUB":
+ case "SUP":
+ case "SPAN":
+ case "U":
+ parent.insertAdjacentElement("afterend", br);
+ parent.remove();
+ break;
+ default:
+ return;
+ }
}
}
function removeTrailingBr(br) {
private function unwrapBr(\DOMElement $br): void
{
- if ($br->previousSibling || $br->nextSibling) {
- return;
- }
+ for (;;) {
+ if ($br->previousSibling || $br->nextSibling) {
+ return;
+ }
- $parent = $br->parentNode;
- switch ($parent->nodeName) {
- case "b":
- case "del":
- case "em":
- case "i":
- case "strong":
- case "sub":
- case "sup":
- case "span":
- case "u":
- $parent->parentNode->insertBefore($br, $parent);
- $parent->parentNode->removeChild($parent);
-
- $this->unwrapBr($br);
- break;
+ $parent = $br->parentNode;
+ switch ($parent->nodeName) {
+ case "b":
+ case "del":
+ case "em":
+ case "i":
+ case "strong":
+ case "sub":
+ case "sup":
+ case "span":
+ case "u":
+ $parent->parentNode->insertBefore($br, $parent);
+ $parent->parentNode->removeChild($parent);
+ break;
+
+ default:
+ return;
+ }
}
}