diff options
author | Asmir Mustafic <[email protected]> | 2014-07-18 12:55:44 +0200 |
---|---|---|
committer | Asmir Mustafic <[email protected]> | 2014-07-18 12:55:44 +0200 |
commit | ebae60bed13e0df3da4c13f7540052d40dee847f (patch) | |
tree | c4c38fc23f6031b5e8d6f6c66c238506b65ea420 /src/HTML5/Parser/DOMTreeBuilder.php | |
parent | d31d82ebe8bf43f88dba8db1a1d9e6c466e06f41 (diff) |
Fixed a HHVM issue (can't reproduce on this project...)
Diffstat (limited to 'src/HTML5/Parser/DOMTreeBuilder.php')
-rw-r--r-- | src/HTML5/Parser/DOMTreeBuilder.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/HTML5/Parser/DOMTreeBuilder.php b/src/HTML5/Parser/DOMTreeBuilder.php index 59504f5..42a55fe 100644 --- a/src/HTML5/Parser/DOMTreeBuilder.php +++ b/src/HTML5/Parser/DOMTreeBuilder.php @@ -346,8 +346,9 @@ class DOMTreeBuilder implements EventHandler $ele = $this->doc->createElement('invalid'); } - // when we add some namespacess, we have to track them. Later, when "endElement" is invoked, we have to remove them - if ($pushes > 0) { + // When we add some namespacess, we have to track them. Later, when "endElement" is invoked, we have to remove them. + // When we are on a void tag, we do not need to care about namesapce nesting. + if ($pushes > 0 && !Elements::isA($name, Elements::VOID_TAG)) { // PHP tends to free the memory used by DOM, // to avoid spl_object_hash collisions whe have to avoid garbage collection of $ele storing it into $pushes // see https://bugs.php.net/bug.php?id=67459 @@ -411,6 +412,14 @@ class DOMTreeBuilder implements EventHandler $this->insertMode = static::IM_IN_BODY; } + // When we are on a void tag, we do not need to care about namesapce nesting, + // but we have to remove the namespaces pushed to $nsStack. + if ($pushes > 0 && Elements::isA($name, Elements::VOID_TAG)) { + // remove the namespaced definded by current node + for ($i = 0; $i < $pushes; $i ++) { + array_shift($this->nsStack); + } + } // Return the element mask, which the tokenizer can then use to set // various processing rules. return Elements::element($name); |