Skip to content

Commit 286e4f3

Browse files
authored
Merge pull request tgalopin#22 from tgalopin/fix-details-ext
Fix details extension and add custom allowed attr test
2 parents 2d17c01 + df92db7 commit 286e4f3

File tree

3 files changed

+259
-118
lines changed

3 files changed

+259
-118
lines changed

src/Extension/Details/Node/DetailsNode.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,4 @@ public function getTagName(): string
2727
{
2828
return 'details';
2929
}
30-
31-
public function render(): string
32-
{
33-
$isOpen = null !== $this->getAttribute('open');
34-
35-
return '<details'.($isOpen ? ' open="open"' : '').'>'.$this->renderChildren().'</details>';
36-
}
3730
}

src/Extension/Details/NodeVisitor/DetailsNodeVisitor.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ public function getDefaultAllowedAttributes(): array
3939

4040
protected function createNode(\DOMNode $domNode, Cursor $cursor): NodeInterface
4141
{
42-
return new DetailsNode($cursor->node);
42+
$node = new DetailsNode($cursor->node);
43+
44+
if (null !== $this->getAttribute($domNode, 'open')) {
45+
$node->setAttribute('open', 'open');
46+
}
47+
48+
return $node;
4349
}
4450
}

0 commit comments

Comments
 (0)