I tried to validate the markup at node/add/article and got the following result:
line 76 column 291 - Warning: discarding unexpected </span>
line 76 column 516 - Warning: discarding unexpected </span>
line 94 column 210 - Warning: discarding unexpected </span>
line 76 column 285 - Warning: inserting implicit <span>
line 76 column 510 - Warning: inserting implicit <span>
line 94 column 204 - Warning: inserting implicit <span>
line 76 column 34 - Warning: missing </span> before <div>
line 76 column 336 - Warning: missing </span> before <div>
line 94 column 34 - Warning: missing </span> before <div>
line 76 column 285 - Warning: trimming empty <span>
line 76 column 510 - Warning: trimming empty <span>
line 94 column 204 - Warning: trimming empty <span>
These warnings appear only if the markup validation is performed after javascript execution (DOM editing).
They refer to the resizable textareas for the node body and teaser editing.
The problem is on line 14 of misc/textarea.js, where a new DIV (class="grippie") is created inside a wrapping SPAN
(block-level element should not be nested inside inline elements):
$(this).wrap('<div class="resizable-textarea"><span></span></div>')
.parent().append($('<div class="grippie"></div>').mousedown(startDrag));
The resulting markup is:
<div class="resizable-textarea">
<span style="display: none;">
<textarea id="edit-teaser-js" class="form-textarea teaser resizable teaser-processed textarea-processed" name="teaser_js" rows="10" cols="60"/>
<div class="grippie" style="margin-right: -6px;"/>
</span>
</div>
Replacing the wrapping SPAN with an DIV fixes the problem.
$(this).wrap('<div class="resizable-textarea"><div></div></div>')
.parent().append($('<div class="grippie"></div>').mousedown(startDrag));
The resulting markup is now correct:
<div class="resizable-textarea">
<div style="display: none;">
<textarea id="edit-teaser-js" class="form-textarea teaser resizable teaser-processed textarea-processed" name="teaser_js" rows="10" cols="60"/>
<div class="grippie" style="margin-right: -6px;"/>
</div>
</div>
Comments
Comment #1
wrwrwr commentedI understand that this span wrapping is to avoid an IE margin bug (as noted in a comment there) and div wouldn't work because it hasLayout(). Could you give some details on how to reproduce this? (I'm getting another validation error on this very page: double node-form id :)
Comment #2
wrwrwr commentedOK, I already got why I don't get those errors, the markup is wrong nevertheless.
However, the IE bug is still there: try adding style="width: 400px; margin-left: 50px; background-color: tan;" to the resizable-textarea div and removing the inner div/span or just adding the style to the inner div. The expected result is that there is no tan bar (e. g. Firefox), but IE adds one margin for the div and another for the textarea ...
Maybe this span wrapping could be factored out into some IE only fixes?
Comment #3
riccardor commented@wrwrwr: thanks for the review.
I casually noticed those warnings while looking for other info with a FF plugin (HTML Validator) that allows to validate pages after javascript execution.
AFAIK the wrapping DIV should work around the IE margin bug, because it hasn't any CSS properties triggering hasLayout.
Being the div a block-level element, however, it doesn't trigger warnings because of the nested grippy div.
It works on IE6 for me, even if I add the style you suggest to the resizable-texarea DIV.
Anyway, we are talking about almost invisible warnings caused by a great work around for an IE bug, and a very difficult one to fix.
If there is a way to slightly improve the fix, I'd be happy. Otherwise it can well stay as it is until people start using better browsers :)
Comment #4
wrwrwr commentedHTML Validator -- of course that's the same thing I'm using :)
The div works, but I imagine this could be a source of some hard to debug bugs, if someone were to trigger the hasLayout of the inner div with some fancy XPath.
What do you say to the following patch: should validate as far as it's not IE, and actually avoids adding an unnecessary div/span for all the other browsers? Tested only with FF3, Opera9 & IE6/Ubuntu.
Comment #6
harking commentedSubscribing
Comment #7
casey commentedtextarea.js is changed. Does this issue still apply?
Comment #8
aspilicious commented"These warnings appear only if the markup validation is performed after javascript execution (DOM editing)."
Can someone explain this...
I validated the suggested page on my localhost and it's all green :)
I don't know how to test after java execution or whatever that means.
Comment #9
casey commentedLooking into the issue, I see the aforementioned SPAN element is gone. I guess this issue is fixed.