mozL10n.localize() may clear an entire element instead of just the first text node

RESOLVED FIXED

Status

defect
RESOLVED FIXED
6 years ago
5 years ago

People

(Reporter: kaze, Assigned: kaze)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

Assignee

Description

6 years ago
Consider the following paragraph:

  <p id="test"> This is a test <button>foo</button> </p>

This adds a `data-l10n-id="message"' attribute to #test and keeps the <button> element:

  mozL10n.localize(document.querySelector('#test'), 'message');

This should clear the `data-l10n-id="message"` attribute and the first text node:

  mozL10n.localize(document.querySelector('#test'), 'message');

but it also clears the <button> element, which is not expected.
Assignee

Updated

6 years ago
Assignee: nobody → kaze
Assignee

Comment 2

6 years ago
(In reply to Fabien Cazenave [:kaze] from comment #0)
> This should clear the `data-l10n-id="message"` attribute and the first text
> node:
> 
>   mozL10n.localize(document.querySelector('#test'), 'message');
> 
> but it also clears the <button> element, which is not expected.

Gosh, I need some PTO. *This* should clear the l10n-id attribute and the first text node:

>   mozL10n.localize(document.querySelector('#test'));

Sorry for the confusion (again).
Assignee

Updated

6 years ago
Depends on: 882591
Comment on attachment 786830 [details]
link to pull request

comments on github

please ask me for review again once it's ready :)
Attachment #786830 - Flags: review?(felash)
Assignee

Comment 4

6 years ago
Comment on attachment 786830 [details]
link to pull request

Comments addressed.
Attachment #786830 - Flags: review?(felash)
Blocks: 886715
Comment on attachment 786830 [details]
link to pull request

r=me with the last comment (that you can decide to keep or not)
Attachment #786830 - Flags: review?(felash) → review+
Assignee

Comment 6

6 years ago
Merged on master:
https://github.com/mozilla-b2g/gaia/commit/e5154bdd600179bccf1931d0775354cddb31cf43
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Component: Gaia → Gaia::L10n
You need to log in before you can comment on or make changes to this bug.