Template contents participate in the DOM tree
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by running the PHP reproduction in the issue and inspect how template contents are added to the DOM during parsing. The fix is done when saveHTML() still serializes the template contents, while the XPath query for the nested div returns an empty DOMNodeList.
Written by the indexing model from the issue text.
Description
The following code:
<?php
require 'vendor/autoload.php';
use Masterminds\HTML5;
$html = new HTML5(array(
"disable_html_ns" => false
));
$dom = $html->loadHTML(<<<HTML
<!DOCTYPE html>
<html>
<body>
<template><div>foo</div></template>
</body>
</html>
HTML);
echo $dom->saveHTML();
$xp = new DOMXPath($dom);
$xp->registerNamespace('html', 'http://www.w3.org/1999/xhtml');
var_dump($xp->query('//html:div'));
Resulted in the following output:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><body>
<template><div>foo</div></template>
</body>
</html>
object(DOMNodeList)#8 (1) {
["length"]=>
int(1)
}
But I expected this instead:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><body>
<template><div>foo</div></template>
</body>
</html>
object(DOMNodeList)#8 (1) {
["length"]=>
int(0)
}
While template contents should be serialized via saveHTML(), they should not participate in the DOM tree and therefore not show up in the DOMNodeList.
Equivalent JS:
dom=(new DOMParser).parseFromString(`<!DOCTYPE html>
<html>
<body>
<template><div>foo</div></template>
</body>
</html>`,'text/html');
console.log(dom.getElementsByTagName('template')[0].firstChild); // null
console.log(dom.documentElement.outerHTML); // Shows template contents
- Dominant language
- HTML
- Stars
- 1.8k
- Forks
- 122
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Masterminds/html5-php
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Masterminds/html5-php#251 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Masterminds/html5-php#250 · 5 comments · 2 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 28/100
Masterminds/html5-php#246 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Masterminds/html5-php#245 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Masterminds/html5-php#244 · 2 comments · 2 reactions ·
All issues in Masterminds/html5-php
Similar issues
-
Browser Waiting for: Product Owner
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
getsentry/sentry-javascript#24577 · 1 comment ·
-
1.0.0-alpha2 Type/Improvement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
wso2/dpdp-accelerator#272 ·
-
light
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
aemdemos/patients-stryker#253 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
clerk/javascript#9852 ·
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
amponce/archive-movie-browser#165 ·