Ticket #223 (new defect)

Opened 19 months ago

Last modified 18 months ago

Attribute names should be lower-case

Reported by: mattias400 Owned by:
Priority: minor Milestone:
Component: editor Version: trunk
Keywords: Cc:


I've been struggling with a problem regarding the colspan attributes.

==Problem== In IE8 the colspan attributes of td elements disappear on update() or on html view on/off toggle.

==Reproduce== To reproduce, use IE8 and paste the following HTML into the html view of a 0.5rc2 editor:

<tr><td colspan="2">wide</td></tr>

Then toggle html off and then on again, and the colspan attribute is gone.

Doing the same thing in Firefox 3.6 keeps the attribute.

==Reason== I've come to the conclusion that the problem is because of a upper/lower case mismatch and a difference between IE and Firefox.

When getting innerHTML of the editor iframe in Firefox, you get this:

<table><tr><td colspan="2">wide</td></tr><tr><td>1</td><td>2</td></tr></table>

When doing the same in IE, you get this:

<TABLE><TR><TD colSpan=2>wide</TD></TR><TR><TD>1</TD><TD>2</TD></TR></TABLE>

The problem is not the upper case of the tags, but the camel case of the attribute. When Wymeditor is validating the attributes, the "colSpan" attribute does not match the valid attributes list (which contains "colspan" in lower case).

==Solution== I think you will find the best solution to this, or maybe you've already done. You can fix it in IE and break it in FF by changing "colspan" to "colSpan" XhtmlValidator._tags. =)

Afraid of breaking something else I have altered the beginning of the for loop of the getValidTagAttributes function as follows:

var value = attributes[attribute];
attribute = attribute.toLowerCase(); // IE case patch
var h = WYMeditor.Helper;

...which fixes the problem temporarily. Probably the problem should be adressed earlier in the code.

Change History

comment:1 Changed 19 months ago by mr_lundis

  • Summary changed from colspan attributes removed in IE8 to Attribute names should be lower-case

According to the xhtml standard all element and attribute names must be in lower-case, thus colSpan is invalid and removed.

To fix this specific issue and to make the parser more reliable in general attribute names should be transformed to lower-case, just like tag names.

comment:2 Changed 18 months ago by weswinham

Implemented mattias400's fix in my table_editing branch and it fixed the issue for me without causing any regressions that I've been able to notice:  https://github.com/winhamwr/wymeditor/commit/6af2a84992d1e8738a18da289b35ac404ec7f145

It seems like all of the attribute validation passes through getValidTagAttributes and adding that one toLowerCase call does the trick.

Note: See TracTickets for help on using tickets.