Revert "[FEATURE] Fluid Tag Builder: Allow empty attributes" 45/41845/4
authorHelmut Hummel <helmut.hummel@typo3.org>
Wed, 22 Jul 2015 18:36:57 +0000 (20:36 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Wed, 22 Jul 2015 18:46:29 +0000 (20:46 +0200)
The change introduced is unfortunately broken conceptually and functionally.

For proper support of empty attributes, we must have the possibility to add
this functionality on an pre attribute basis to not interfere with attributes
which are not allowed to be specified in empty attribute syntax.

Resolves: #68474
Reverts: #67372
Releases: master
This reverts commit ee6f545a216c102af523d571f4b5d83af507503d.
Change-Id: Idd0af9d3164adc91a7e8ad9e0c554467cce0d233
Reviewed-on: http://review.typo3.org/41845
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
Reviewed-by: Marc Bastian Heinrichs <typo3@mbh-software.de>
Tested-by: Marc Bastian Heinrichs <typo3@mbh-software.de>
typo3/sysext/core/Documentation/Changelog/master/Feature-67372-AllowEmptyAttributeSyntaxInFluidTagBuilder.rst [deleted file]
typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractTagBasedViewHelper.php [changed mode: 0755->0644]
typo3/sysext/fluid/Classes/Core/ViewHelper/TagBuilder.php
typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/AbstractTagBasedViewHelperTest.php [changed mode: 0755->0644]
typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/TagBuilderTest.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-67372-AllowEmptyAttributeSyntaxInFluidTagBuilder.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-67372-AllowEmptyAttributeSyntaxInFluidTagBuilder.rst
deleted file mode 100644 (file)
index 9a903fe..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-==================================================================
-Feature: #67372 - Allow empty attribute syntax in fluid TagBuilder
-==================================================================
-
-Description
-===========
-
-Tags built with the TagBuilder may have empty attributes as they are allowed in the `HTML specifications`_ and are broadly supported by web browsers.
-The way to create empty attributes is to use ``->addAttribute($key, $value)`` or ``->addAttributes($array)`` just like before and provide an empty string as attribute value.
-
-
-Impact
-======
-
-If someone used an empty string as attribute value before, it will now be rendered with the empty attribute syntax which is exactly the same (according to the HTML specification).
-
-
-Examples
-========
-
-Usage example:
-
-.. code-block:: php
-
-       $this->tag->addAttribute('disabled', ''); // results in a tag like: <input disabled />
-
-.. _HTML specifications: http://www.w3.org/TR/html-markup/syntax.html#syntax-attributes
old mode 100755 (executable)
new mode 100644 (file)
index e55381f..5e80f6c
@@ -80,7 +80,7 @@ abstract class AbstractTagBasedViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelp
 
                if (isset(self::$tagAttributes[get_class($this)])) {
                        foreach (self::$tagAttributes[get_class($this)] as $attributeName) {
-                               if ($this->hasArgument($attributeName)) {
+                               if ($this->hasArgument($attributeName) && $this->arguments[$attributeName] !== '') {
                                        $this->tag->addAttribute($attributeName, $this->arguments[$attributeName]);
                                }
                        }
index dd7455a..07f1e83 100644 (file)
@@ -226,11 +226,7 @@ class TagBuilder {
                }
                $output = '<' . $this->tagName;
                foreach ($this->attributes as $attributeName => $attributeValue) {
-                       if ($attributeValue === '' && $GLOBALS['TSFE']->config['config']['doctype'] === 'html5') {
-                               $output .= ' ' . $attributeName;
-                       } else {
-                               $output .= ' ' . $attributeName . '="' . $attributeValue . '"';
-                       }
+                       $output .= ' ' . $attributeName . '="' . $attributeValue . '"';
                }
                if ($this->hasContent() || $this->forceClosingTag) {
                        $output .= '>' . $this->content . '</' . $this->tagName . '>';
old mode 100755 (executable)
new mode 100644 (file)
index 561f9fd..4d0f03b
@@ -53,20 +53,6 @@ class AbstractTagBasedViewHelperTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
        /**
         * @test
         */
-       public function emptyTagAttributeCallsTagBuilder() {
-               $mockTagBuilder = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder::class, array('addAttribute'), array(), '', FALSE);
-               $mockTagBuilder->expects($this->once())->method('addAttribute')->with('foo', '');
-               $this->viewHelper->_set('tag', $mockTagBuilder);
-
-               $this->viewHelper->_call('registerTagAttribute', 'foo', 'string', 'Description', FALSE);
-               $arguments = array('foo' => '');
-               $this->viewHelper->setArguments($arguments);
-               $this->viewHelper->initialize();
-       }
-
-       /**
-        * @test
-        */
        public function additionalTagAttributesAreRenderedCorrectly() {
                $mockTagBuilder = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder::class, array('addAttribute'), array(), '', FALSE);
                $mockTagBuilder->expects($this->once())->method('addAttribute')->with('foo', 'bar');
index 69fd807..2b8c7dd 100644 (file)
@@ -115,21 +115,6 @@ class TagBuilderTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        /**
         * @test
         */
-       public function emptyAttributesAreRenderedAccordingToHtmlDoctype() {
-               $GLOBALS['TSFE']->config['config']['doctype'] = 'html5';
-               $tagBuilder = new \TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder('tag');
-               $tagBuilder->addAttribute('attribute1', '');
-               $this->assertEquals('<tag attribute1 />', $tagBuilder->render(), 'Empty attribute syntax is used for HTML5 doctype');
-               $tagBuilder->reset();
-               $GLOBALS['TSFE']->config['config']['doctype'] = 'xhtml_trans';
-               $tagBuilder->setTagName('tag');
-               $tagBuilder->addAttribute('attribute1', '');
-               $this->assertEquals('<tag attribute1="" />', $tagBuilder->render(), 'Key value attribute syntax is used for XHTML doctype');
-       }
-
-       /**
-        * @test
-        */
        public function attributeValuesAreEscapedByDefault() {
                $tagBuilder = new \TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder('tag');
                $tagBuilder->addAttribute('foo', '<to be escaped>');