Project

General

Profile

Actions

Bug #29855

closed

Tag attributes are reversed on save, clutters workspace compares.

Added by Bart Dubelaar about 13 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Should have
Category:
RTE (rtehtmlarea + ckeditor)
Target version:
Start date:
2011-09-15
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
4.5
PHP Version:
5.3
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

Description

When saving a content element, the order of attributes of img and a tags is reversed. This happens on every save. For the frontend output this is of course no problem, but it clutters the workspace diffs with many changes. So in the end it is very hard to see the changes that do matter. See attached screenshot.
Is there a setting that can change this behavior? Or is it a bug?


Files

snapshot10.png (26.6 KB) snapshot10.png Bart Dubelaar, 2011-09-15 16:35
patch.diff (797 Bytes) patch.diff patch for htmlarea.js (add sorting) Bart Dubelaar, 2011-09-26 10:42
Actions #1

Updated by Tobias Liebig about 13 years ago

  • Complexity set to easy

i'd consider this a bug.
Should not be hard to fix.

Actions #2

Updated by Bart Dubelaar about 13 years ago

Can anyone point me in the right direction on where to look in the code?

Actions #3

Updated by Bart Dubelaar about 13 years ago

OK, did some additional investigations. The tag parameters are reversed when the existing content is loaded from the DB into the RTE for editing. Disabling the RTE will show the content correctly in the editing form.

Important finding: It only happens in Google Crome, not in FireFox! Apparently there is a JS function that parses the tags. You can also see the problem when hitting the 'show html' button in the RTE toolbar. In Chrome you will see the parameters swapping around.

Actions #4

Updated by Bart Dubelaar about 13 years ago

I've found the root of the problem. The problem lies in the getAttributes function in htmlarea.js. This function uses the DOM method node.attributes to get the list of attributes of a node, parse them, and then pass them through to reconstruct tags with the fetched attributes.
However, the method .attributes returns a NamedNodeMap which is not an array. See this definition:

.attributes is a collection of all attribute nodes registered to the specified node. It is a NamedNodeMap,not an Array, so it has no Array methods and the Attr nodes' indexes may differ among browsers.

So this method should not be used for such processes, as the order will not reflect the original order in the source, and differs among browsers. Unfortunately there are no other methods to get all attributes from a node. I also tried to just alter the nodes directly instead of dismantling them and rebuilding them later on, but then I bumped into the problem that there is no uniform method to convert a node to flat html (outerHTML doesn't work in FF).

So in the end, the only solution I could come up with is to just sort everything alphabetically all the time. This will result in some funky html, but at least it is consistent. I will provide a patch next week.

Actions #5

Updated by Bart Dubelaar about 13 years ago

Actions #6

Updated by Mr. Hudson about 13 years ago

Patch set 1 of change Ib5f46fc0399afbbfd4b436fc5aee75fe52f7ac10 has been pushed to the review server.
It is available at http://review.typo3.org/5379

Actions #7

Updated by Mr. Hudson about 13 years ago

Patch set 2 of change Ib5f46fc0399afbbfd4b436fc5aee75fe52f7ac10 has been pushed to the review server.
It is available at http://review.typo3.org/5379

Actions #8

Updated by Stanislas Rolland about 13 years ago

  • Assignee set to Stanislas Rolland
  • Target version set to 4.4.12
  • PHP Version set to 5.3

The issue arises in WebKit (Safari and Chrome) and Opera.

Actions #9

Updated by Stanislas Rolland about 13 years ago

  • Target version changed from 4.4.12 to 4.5.7
Actions #10

Updated by Mr. Hudson about 13 years ago

Patch set 1 of change I4686dc9a1a0a7a81b06ee6b6430371e86b593817 has been pushed to the review server.
It is available at http://review.typo3.org/5535

Actions #11

Updated by Mr. Hudson about 13 years ago

Patch set 1 of change I8de914e0f10b043c106c1cacba3e17579d43e699 has been pushed to the review server.
It is available at http://review.typo3.org/5536

Actions #12

Updated by Stanislas Rolland about 13 years ago

Please test this change: http://review.typo3.org/5536

Actions #13

Updated by Stanislas Rolland about 13 years ago

  • Status changed from New to Under Review
Actions #14

Updated by Mr. Hudson about 13 years ago

Patch set 2 of change I4686dc9a1a0a7a81b06ee6b6430371e86b593817 has been pushed to the review server.
It is available at http://review.typo3.org/5535

Actions #15

Updated by Mr. Hudson about 13 years ago

Patch set 2 of change I8de914e0f10b043c106c1cacba3e17579d43e699 has been pushed to the review server.
It is available at http://review.typo3.org/5536

Actions #16

Updated by Stanislas Rolland about 13 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #17

Updated by Riccardo De Contardi about 7 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF