Review main Abandoned

5379[BUGFIX] inconsistent ordering of tag parameters by RTE

Bart Dubelaar CR 0 V 0 Easy +8 −5 updated 06/03/13, 20:49

Commit message

When saving a content element the order of attributes of <img> and <a> tags is reversed in some browsers.
This happens on every save. For the frontend output this is of course no problem,
but it clutters the workspace diffs with many unwanted changes.
As a result it is very hard to see the changes that do matter. The problem is very well reproducable.
Open an RTE in Google Chrome and switch back and forth to html code view, you will see the parameters swapping around.

The root of the problem lies in the fact that the javascript DOM method node.attributes is used to fetch all attributes of a node.
When parsing content the original node is disregarded by htmlarea and a new tag is constructed using the fetched node attributes.

However the specification of the DOM method node.attributes states that this function does not produce an array with a
specified order, and that its implementation may differ among browsers. And so it does. The order of the attributes is
different among browsers. This is problematic when different editors use different browsers to start with. But in Chrome the
problem is even more prominent as the order is reversed on every save.

This bugfix addresses the problem by sorting all attributes alphabetically all the time. This fixes the bug, however is results in unusual
html formatting. A better solution could be desirable but might require a rigorous overhaul of code. As the effects on working with workspaces are
quite big, sorting alphabetically might be the best solution for now.

Review

  • Code review CR 0

    Imported before Forger kept the single votes, the next import adds them.

  • Verified V 0

    Imported before Forger kept the single votes, the next import adds them.

Issues 1

Files 1