vhs icon indicating copy to clipboard operation
vhs copied to clipboard

v:tag adds additionalAttributes even if their value is empty

Open cweiske opened this issue 9 years ago • 6 comments
trafficstars

The description of <v:tag> says:

Creates one HTML tag of any type, with various properties like class and ID applied only if arguments are not empty, rather than apply them always - empty or not - if provided.

Unfortunately, all attributes brought in via additionalAttributes are added always, regardless of their value.

This makes it hard to create a <video> tag without a poster attribute when the respective variable is empty.

cweiske avatar Sep 29 '16 06:09 cweiske

I think this makes sense as a general feature for Fluid itself, as part of AbstractTagBasedViewHelper. We could achieve this with an additional argument for any TagBasedViewHelper, for example ignoreEmptyAttributes or skipEmptyAttributes with a default of FALSE (at least until we are ready for a breaking change). Right now VHS needs a list of attribute names that must be ignored if empty (default is ['id', 'class']) and the Trait is designed to let you pass this array from implementing classes. You are most welcome to submit a PR to, for example, allow defining these attribute names as an argument for v:tag - but I am not sure we should be changing the behavior of additionalAttributes here, compared to any other TagBasedViewHelper (like the Form ones). That's where we need a general feature.

The conclusion looks like:

  • We can make it possible to do this for root arguments excluding additionalAttributes in VHS's TagViewHelperTrait (it would also be possible to target the universal tag attributes).
  • We cannot make this a generally supported thing on 7.6, but we can add it to standalone Fluid to get access in TYPO3 8.4 and above.
  • The only reason for not wanting to touch additionalAttributes in TagViewHelperTrait is it would add to the confusion if VHS TagBasedViewHelpers handled it one way and and core ones did it another way. That said, if the behavior is opt-in, I would consider a pull request to add that.

Would you mind opening a feature request for https://github.com/TYPO3Fluid/Fluid so we at least get it added there at some point?

NamelessCoder avatar Sep 29 '16 12:09 NamelessCoder

issue opened.

cweiske avatar Mar 15 '17 13:03 cweiske

Available as Fluid core feature since Fluid 2.4.0 - https://github.com/TYPO3/Fluid/pull/302.

NamelessCoder avatar Sep 15 '17 13:09 NamelessCoder

It seems as if the base feature (ignoreEmptyAttributes) is available in fluid core, but no attribute in v:tag exposes this option. Please reopen.

cweiske avatar Mar 04 '24 10:03 cweiske

The problem still applies with vhs 6.1.2.

cweiske avatar Oct 28 '24 09:10 cweiske

Issue reopened but there will be no more releases for the 6.x branch - the fix will be 7.x only!

NamelessCoder avatar Oct 28 '24 10:10 NamelessCoder