Closed Bug 1161807 Opened 9 years ago Closed 9 years ago

[RTL] changing textContent on dir=auto element from RTL to phone number does not update direction

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1103348
Tracking Status
firefox40 --- affected

People

(Reporter: mikehenrty, Unassigned)

Details

Attachments

(1 file)

Attached file [HTML page] test case
When an element has dir=auto set, and is populated with RTL text (like Arabic), if you then set the textContent to a phone number (like +15554443333), the text direction will stay in RTL mode. However, if you do not have Arabic text populated first and set the text to the phone number, the element will correctly use the LTR direction. See attached test case.
This is blocking a blocker. David, do you know what is going on here? It looks like we can work around this issue by temporarily setting an LRT textContent ("A" for instance) to the element before setting the phone number, but this would be less than ideal.
Flags: needinfo?(dbaron)
The current behaviour in the testcase is strange and inconsistent and need to be fixed, but I'm not sure that the behaviour you want is what the spec says should happen: a phone number has no strong directional characters, so a <div> with dir="auto" whose text content is only a phone number has the same directionality as its parent. An <input> or a <textarea>, on the other hand, defaults to ltr if it contains no strong directional characters. 

https://html.spec.whatwg.org/multipage/dom.html#the-dir-attribute

Ehsan, do you remember why the spec makes this distinction?
Flags: needinfo?(ehsan)
FWIW, the behavior here sounds like it might be related to the case described in bug 1103348.
Wow, yes. I had no memory of that bug at all, in spite of having written a lengthy comment in it. Apparently international travel causes retrogressive amnesia for me :(
Depends on: 1103348
(In reply to Simon Montagu :smontagu from comment #2)
> The current behaviour in the testcase is strange and inconsistent and need
> to be fixed, but I'm not sure that the behaviour you want is what the spec
> says should happen: a phone number has no strong directional characters, so
> a <div> with dir="auto" whose text content is only a phone number has the
> same directionality as its parent.

But that's not how gecko works right now, see http://jsbin.com/jebahefunu/1/edit?html,output for example. When we use "dir=auto" the phone number is LTR in a RTL document.

This helps us a lot currently :) if the behavior changes we'll have to do a lot of fixes in the comms apps like SMS.
(In reply to Simon Montagu :smontagu from comment #2)
> Ehsan, do you remember why the spec makes this distinction?

I kind of remember that there was a (good?) reason, but unfortunately don't remember anything more.

(In reply to Julien Wajsberg [:julienw] (PTO May 8th -> May 17th) from comment #5)
> (In reply to Simon Montagu :smontagu from comment #2)
> > The current behaviour in the testcase is strange and inconsistent and need
> > to be fixed, but I'm not sure that the behaviour you want is what the spec
> > says should happen: a phone number has no strong directional characters, so
> > a <div> with dir="auto" whose text content is only a phone number has the
> > same directionality as its parent.
> 
> But that's not how gecko works right now, see
> http://jsbin.com/jebahefunu/1/edit?html,output for example. When we use
> "dir=auto" the phone number is LTR in a RTL document.
> 
> This helps us a lot currently :) if the behavior changes we'll have to do a
> lot of fixes in the comms apps like SMS.

If I'm reading the spec wrong, this seems like a bug.  But I'm not sure why Chrome and Safari both behave the same.  :/
Flags: needinfo?(ehsan)
This is a dupe of bug 1103348.  My patch for that bug fixes this too.
Status: NEW → RESOLVED
Closed: 9 years ago
No longer depends on: 1103348
Flags: needinfo?(dbaron)
Resolution: --- → DUPLICATE
No longer blocks: 1156200
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: