cleanExtraTags (and cleanExtraBrTags) Dom Modifiers don't properly account for multiple selector matches

Created on 24 August 2023, over 1 year ago
Updated 17 December 2023, about 1 year ago

I'm not completely clear on what the historical goal of cleanExtraTags is, but I expected it to clean the designated tags from the front/end of the innerHTML of all the elements that matched my given selector.

Instead what it actually does is finds the first element that matches the selector, cleans the tags from that HTML, then proceeds to *replace every matching tag with the markup generated from the replacement done on the first matching tag*. I doubt this is the intended behavior. Patch forthcoming.

πŸ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States azinck

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @azinck
  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States azinck
  • πŸ‡ΊπŸ‡ΈUnited States azinck

    Here's a further change that is possibly a bit more controversial, but I think it's in the spirit of what this method is meant to do. This updates the previous patch to strip ALL of the instances of the given tag from the beginning/end of the markup. This is how I expected the function to work given the fact that "Tags" is plural in "cleanExtraTags" (it's not "cleanExtraTag").

    So if you have something like:

    <p>Text goes here.<br><br><br><br></p>
    

    Then ALL of the
    tags will be stripped when you run that through cleanExtraBrTags with this patch.

  • πŸ‡ΊπŸ‡ΈUnited States swirt Florida

    @azinck, thank you so much for your work on this and the contribution. I am sorry for letting this sit so long without responding.

    I think your approach is right. I need a good way to test this and at the moment I don't have a good existing migration to try it out with. I am going to need a little time to test this out.

Production build 0.71.5 2024