-
Notifications
You must be signed in to change notification settings - Fork 106
Description
Right now
$tagBuilder->addAttribute('attr', NULL); // ->getAttribute('attr') returns NULL, and ->render() results attr=""
$tagBuilder->addAttribute('attr', TRUE); // ->getAttribute('attr') returns 'attr', and ->render() results attr="attr"
$tagBuilder->addAttribute('attr', FALSE); // ->getAttribute('attr') returns NULL as the attribute has been removed, and ->render() results nothing.
I think it's a little messing. What I expected are:
$tagBuilder->addAttribute('attr', NULL); // removes the attribute, and ->render() results nothing
$tagBuilder->addAttribute('attr', TRUE); // ->getAttribute('attr') returns TRUE, and ->render() results attr or attr="attr"
$tagBuilder->addAttribute('attr', FALSE); // ->getAttribute('attr') returns FALSE, and ->render() results nothing or maybe attr="".
So for ->render(), considering the output for HTML5 and XHTML, I think it's better to introduce a new property and affect the final result according to its value.
Thanks!