Closed Bug 936534 Opened 8 years ago Closed 8 years ago

l10n.js should use setAttribute for setting attributes of HTML elements

Categories

(Firefox OS Graveyard :: Gaia::L10n, defect, P4)

defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 994290

People

(Reporter: stas, Assigned: zbraniecki)

References

Details

Attachments

(2 files)

Curerntly, l10n.js uses the element[property] syntax.  The proper approach is to use setAttribute().

To minimize the need for rebasing, let's fix this once bug 914414 lands.
Assignee: nobody → gandalf
Attached patch patchSplinter Review
This is a small patch.

A bigger one will go in bug 994290.
Attachment #8404190 - Flags: review?(stas)
Before I review this, I'd like to see a patch against the Gaia repo, with relevant tests fixed.  For instance, in apps/gallery/test/unit/l10n/l10n_test.js you'll find:

      assert.equal(elem.prop, 'this is another property');
      assert.equal(elem.getAttribute('aria-label'), 'label via ARIA');

This should be unified to getAttribute, I believe.
Attached patch patch, gaia partSplinter Review
Attachment #8404501 - Flags: review?(stas)
Comment on attachment 8404190 [details] [diff] [review]
patch

Review of attachment 8404190 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with a question.

Should we also change the line above the patch, which currently looks like the following?

  element[key.substr(0, pos)][key.substr(pos + 1)] = attr;

This could use setProperty for 'style', but not for 'dataset'.  It would also need a camelCase function to convert names of properties.

My take is 'no', and judging from the patch, you're against it as well, but I just want to make sure.
Attachment #8404190 - Flags: review?(stas) → review+
Comment on attachment 8404501 [details] [diff] [review]
patch, gaia part

Review of attachment 8404501 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks. Not many changes, cool.  Can you create a pull request for Gaia?
Attachment #8404501 - Flags: review?(stas) → review+
Comment on attachment 8404190 [details] [diff] [review]
patch

Review of attachment 8404190 [details] [diff] [review]:
-----------------------------------------------------------------

Actually, I'm afraid this is an r-.  I just realized that this will break all the foo.innerHTML we do in Gaia to insert HTML element in the translations.  Let's first fix bug 994357, get rid of innerHTML in the properties files, and revisit this bug.
Attachment #8404190 - Flags: review+ → review-
Depends on: 994357
(In reply to Staś Małolepszy :stas from comment #4)
> Should we also change the line above the patch, which currently looks like
> the following?
> 
>   element[key.substr(0, pos)][key.substr(pos + 1)] = attr;

No. That's bug 994290.
Component: Gaia → Gaia::L10n
OS: Linux → All
Hardware: x86_64 → All
Blocks: 999779
Priority: -- → P4
I just landed a patch for bug 994290 which basically fixes this. 

The only remaining piece is innerHTML exception which is going to be fixed by bug 994357.

I'm marking this bug as a DUPE of 994290.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 994290
You need to log in before you can comment on or make changes to this bug.