Browse Source

Match template behaviour to other implementations

Templates are completely ignored in all circumstances, not just their
contents.
master
J. King 11 months ago
parent
commit
1dde3208bd
  1. 10
      lib/Microformats/Parser.php
  2. 6
      tests/cases/mensbeam/default-settings/template.json

10
lib/Microformats/Parser.php

@ -355,12 +355,12 @@ class Parser {
* @param \DOMElement $node The element to start searching from, including itself
*/
protected function getRootCandidates(\DOMElement $node): void {
$query = [
"self::*[not(ancestor::template)]",
".//*[contains(concat(' ', normalize-space(@class)), ' h-') and not(ancestor::template)]",
// NOTE: Templates being completely ignored is an unwritten rule followed by all implementations
$query = [
"descendant-or-self::*[contains(concat(' ', normalize-space(@class)), ' h-') and not(ancestor-or-self::template)]",
];
foreach (array_keys(static::BACKCOMPAT_ROOTS) as $root) {
$query[] = ".//*[contains(concat(' ', normalize-space(@class), ' '), ' $root ') and not(ancestor::template)]";
$query[] = "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' $root ') and not(ancestor-or-self::template)]";
}
$query = implode("|", $query);
$this->roots = iterator_to_array($this->xpath->query($query, $node));
@ -1462,6 +1462,7 @@ class Parser {
$next = $node->nextSibling;
}
while ($next && (!$next instanceof \DOMElement || $next->localName === "template")) {
// NOTE: Templates being completely ignored is an unwritten rule followed by all implementations
$next = $next->nextSibling;
}
while (!$next) {
@ -1471,6 +1472,7 @@ class Parser {
}
$next = $node->nextSibling;
while ($next && (!$next instanceof \DOMElement || $next->localName === "template")) {
// NOTE: Templates being completely ignored is an unwritten rule followed by all implementations
$next = $next->nextSibling;
}
}

6
tests/cases/mensbeam/default-settings/template.json

@ -69,12 +69,6 @@
""
]
}
},
{
"type": [
"h-test"
],
"properties": {}
}
],
"rels": {},

Loading…
Cancel
Save