Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Issue 3104: Form\Element "x-..." attributes #5424

Closed
wants to merge 2 commits into from

3 participants

@ThaDafinser

Treat x- attributes like data- attributes

#3104

@weierophinney weierophinney closed this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/5424'
Close #5424
Fixes #3104
29ae331
@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/5424' into develop
Forward port #5424
f9d1969
@weierophinney weierophinney was assigned
@grizzm0

So far we've never accepted any PRs that would make it possible to render invalid HTML. Should we really start doing that now? We've already said no to the ng- prefix (sure, data-ng works aswell so it doesn't mater).

ping @weierophinney

@weierophinney

@grizzm0 The problem is that different JS libraries have standardized on different prefixes. I honestly would like to add ng-* to the mix at this time as well; I think limiting to strict, while an interesting goal, limits (pun intended) the use cases tremendously at this time. (Yes, I've changed my position over time.)

@grizzm0

@weierophinney Well, ng-* and other PRs were declined in the past as they would be generate invalid HTML. In the AngularJS case it wasn't a problem as they internally translate all data-ng-* to ng-*. The x- prefix is for experimental attributes. Imho we shouldn't promote the use of non-standard or experimental attributes. If a developer would like to use any of them they should extend the base class to allow the rendering of invalid HTML if you ask me.

@ThaDafinser

@grizzm0 i think we definetly do not promote those attributes. But with the growing use of such attributes, it's absolutely necessary, that such attributes are allowed.

The only thing what came up in my mind is, that we could make an option for "strict standard" rendering or render just every attribute?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 6, 2013
  1. @ThaDafinser

    Test for x-autocomplete

    ThaDafinser authored
  2. @ThaDafinser
This page is out of date. Refresh to see the latest.
View
1  library/Zend/Form/View/Helper/AbstractHelper.php
@@ -351,6 +351,7 @@ protected function prepareAttributes(array $attributes)
if (!isset($this->validGlobalAttributes[$attribute])
&& !isset($this->validTagAttributes[$attribute])
&& 'data-' != substr($attribute, 0, 5)
+ && 'x-' != substr($attribute, 0, 2)
) {
// Invalid attribute for the current tag
unset($attributes[$key]);
View
1  tests/ZendTest/Form/ElementTest.php
@@ -34,6 +34,7 @@ public function testCanAddManyAttributesAtOnce()
'type' => 'text',
'class' => 'text-element',
'data-foo' => 'bar',
+ 'x-autocompletetype' => 'email'
);
$element->setAttributes($attributes);
$this->assertEquals($attributes, $element->getAttributes());
Something went wrong with that request. Please try again.