coderifous / jquery-localize

a jQuery plugin that makes it easy to internationalize your web site.
465 stars 142 forks source link

Is it better to using 'key = elem.attr("data-localize");'? #69

Open JiYouMCC opened 8 years ago

JiYouMCC commented 8 years ago

In line L98

The scenario is that there a element's data-localize will change by js. Then doing localize will cause issue

example:

var a = $("<div></div>").attr("data-localize", 1);
 > undefined
a
 > [<div data-localize=​"1">​</div>​]
a.data()
 > Object {localize: 1}

if change the attr data-localize

a.attr("data-localize", 2)
 > [<div data-localize=​"2">​</div>​]
a.data()
 > Object {localize: 1}
a.attr("data-localize")
> "2"

Now I use workaround in my repository. The workaround seems so ugly...

$("#....").data("localize", newValue).attr("data-localize", newValue)