-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removed empty attribute #28
Comments
I have created this quick patch but i don't like very much that placeholder: use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Goetas\Twital\EventDispatcher\SourceEvent;
use Goetas\Twital\EventDispatcher\TemplateEvent;
class CompatibilitySubscriber implements EventSubscriberInterface {
const PLACEHOLDER = 'placeholderXXX###===';
public static function getSubscribedEvents() {
return [
'compiler.pre_dump' => [
['valueAddPlaceholder']
],
'compiler.post_dump' => [
['valueRemovePlaceholder']
],
];
}
public function valueAddPlaceholder(TemplateEvent $event) {
$doc = $event->getTemplate()->getDocument();
$xp = new \DOMXPath($doc);
$xp->registerNamespace('xh', 'http://www.w3.org/1999/xhtml');
/**
* @var $option \DOMElement
*/
foreach ($xp->query("//xh:option[@value='']") as $option) {
$option->setAttribute('value', self::PLACEHOLDER);
}
}
public function valueRemovePlaceholder(SourceEvent $event) {
$event->setTemplate(str_replace(
' value="' . self::PLACEHOLDER . '"',
' value=""',
$event->getTemplate())
);
}
} |
It should be an https://github.com/Masterminds/html5-php issue.. i will check it |
See Masterminds/html5-php#84, it will be fixed soon |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Twital is removing empty attributes which is fine for most elements except OPTION. IE9 will use option text as value if there is missing value attribute.
Expected output:
Actual output:
The text was updated successfully, but these errors were encountered: