omg broken sibling that killed caption + tr + tr for eample

This commit is contained in:
Adam D. Ruppe 2020-06-13 18:49:12 -04:00
parent e1aa0b2bf9
commit 0dac4f50c5
1 changed files with 36 additions and 3 deletions

39
dom.d
View File

@ -2132,6 +2132,11 @@ class Element {
return p; return p;
} }
///.
@property Element previousElementSibling() {
return previousSibling("*");
}
///. ///.
@property Element previousSibling(string tagName = null) { @property Element previousSibling(string tagName = null) {
if(this.parentNode is null) if(this.parentNode is null)
@ -2142,15 +2147,18 @@ class Element {
break; break;
if(tagName == "*" && e.nodeType != NodeType.Text) { if(tagName == "*" && e.nodeType != NodeType.Text) {
ps = e; ps = e;
break; } else if(tagName is null || e.tagName == tagName)
}
if(tagName is null || e.tagName == tagName)
ps = e; ps = e;
} }
return ps; return ps;
} }
///.
@property Element nextElementSibling() {
return nextSibling("*");
}
///. ///.
@property Element nextSibling(string tagName = null) { @property Element nextSibling(string tagName = null) {
if(this.parentNode is null) if(this.parentNode is null)
@ -2617,6 +2625,18 @@ class Element {
children = null; children = null;
} }
/// History: added June 13, 2020
Element appendSibling(Element e) {
parentNode.insertAfter(this, e);
return e;
}
/// History: added June 13, 2020
Element prependSibling(Element e) {
parentNode.insertBefore(this, e);
return e;
}
/++ /++
Appends the given element to this one. If it already has a parent, it is removed from that tree and moved to this one. Appends the given element to this one. If it already has a parent, it is removed from that tree and moved to this one.
@ -6956,6 +6976,8 @@ int intFromHex(string hex) {
bool oddChild; ///. bool oddChild; ///.
bool evenChild; ///. bool evenChild; ///.
bool scopeElement; /// the css :scope thing; matches just the `this` element. NOT IMPLEMENTED
bool rootElement; ///. bool rootElement; ///.
int separation = -1; /// -1 == only itself; the null selector, 0 == tree, 1 == childNodes, 2 == childAfter, 3 == youngerSibling, 4 == parentOf int separation = -1; /// -1 == only itself; the null selector, 0 == tree, 1 == childNodes, 2 == childAfter, 3 == youngerSibling, 4 == parentOf
@ -7007,6 +7029,7 @@ int intFromHex(string hex) {
if(oddChild) ret ~= ":odd-child"; if(oddChild) ret ~= ":odd-child";
if(evenChild) ret ~= ":even-child"; if(evenChild) ret ~= ":even-child";
if(rootElement) ret ~= ":root"; if(rootElement) ret ~= ":root";
if(scopeElement) ret ~= ":scope";
return ret; return ret;
} }
@ -7061,6 +7084,12 @@ int intFromHex(string hex) {
} }
} }
} }
/+
if(scopeElement) {
if(e !is this_)
return false;
}
+/
if(emptyElement) { if(emptyElement) {
if(e.children.length) if(e.children.length)
return false; return false;
@ -7520,6 +7549,7 @@ int intFromHex(string hex) {
if(!part.matchElement(where)) if(!part.matchElement(where))
return false; return false;
} else if(lastSeparation == 2) { // the + operator } else if(lastSeparation == 2) { // the + operator
//writeln("WHERE", where, " ", part);
where = where.previousSibling("*"); where = where.previousSibling("*");
if(!part.matchElement(where)) if(!part.matchElement(where))
@ -7738,6 +7768,9 @@ int intFromHex(string hex) {
current.firstChild = true; current.firstChild = true;
current.lastChild = true; current.lastChild = true;
break; break;
case "scope":
current.scopeElement = true;
break;
case "empty": case "empty":
// one with no children // one with no children
current.emptyElement = true; current.emptyElement = true;