[BUGFIX] rtehtmlarea: Fix isRequiredClass check 92/50692/3
authorBenjamin Franzke <bfr@qbus.de>
Thu, 17 Nov 2016 08:34:14 +0000 (09:34 +0100)
committerSusanne Moog <susanne.moog@typo3.org>
Wed, 7 Dec 2016 13:06:35 +0000 (14:06 +0100)
Given the following TSConfig:

  RTE {
    classes {
      btn-default {
        name = Default Button
        requires = btn
      }
      btn-primary {
        name = Primary Button
        requires = btn
      }
      btn.selectable = 0
    }
  }

The incorrect isRequiredClass check causes the btn class to be
removed from the RTE toolbarbuttons. This happens because it's
considered unneeded in DOM.removeClass(), which is called by
DOM.addClass() (to remove incompatible classes).

The check in isRequiredClass was probably copied from
some classesRequired lookups, but forgot to inverse the
class that's searched for.

This also fixes the RTE to properly remove the selectable=0 class
(e.g. btn), when a class that requires the aformentioned is removed
(e.g. btn-primary).

Releases: master, 7.6
Resolves: #78730
Change-Id: I5a6ac42c7080835d5018608ab17a39b36a0fb70a
Reviewed-on: https://review.typo3.org/50692
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/rtehtmlarea/Resources/Public/JavaScript/HTMLArea/DOM/DOM.js

index 733c617..df78567 100644 (file)
@@ -220,7 +220,7 @@ define(['TYPO3/CMS/Rtehtmlarea/HTMLArea/UserAgent/UserAgent',
                        if (typeof HTMLArea.classesRequiredBy !== 'undefined') {
                                var classes = Dom.getClassNames(node);
                                for (var i = classes.length; --i >= 0;) {
-                                       if (typeof HTMLArea.classesRequiredBy[classes[i]] !== 'undefined' && HTMLArea.classesRequiredBy[classes[i]].indexOf(className) !== -1) {
+                                       if (typeof HTMLArea.classesRequiredBy[className] !== 'undefined' && HTMLArea.classesRequiredBy[className].indexOf(classes[i]) !== -1) {
                                                return true;
                                        }
                                }