@@ -23,7 +23,7 @@ const TEXT_LEVEL_ELEMENTS = {
23
23
24
24
const LOCALIZABLE_ATTRIBUTES = {
25
25
"http://www.w3.org/1999/xhtml" : {
26
- global : [ "title" , "aria-label" , "aria-valuetext" , "aria-moz-hint" ] ,
26
+ global : [ "title" , "aria-label" , "aria-valuetext" ] ,
27
27
a : [ "download" ] ,
28
28
area : [ "download" , "alt" ] ,
29
29
// value is special-cased in isAttrNameLocalizable
@@ -39,11 +39,13 @@ const LOCALIZABLE_ATTRIBUTES = {
39
39
} ,
40
40
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" : {
41
41
global : [
42
- "accesskey" , "aria-label" , "aria-valuetext" , "aria-moz-hint" , "label"
42
+ "accesskey" , "aria-label" , "aria-valuetext" , "label" ,
43
+ "title" , "tooltiptext"
43
44
] ,
45
+ description : [ "value" ] ,
44
46
key : [ "key" , "keycode" ] ,
45
- textbox : [ "placeholder " ] ,
46
- toolbarbutton : [ "tooltiptext " ] ,
47
+ label : [ "value " ] ,
48
+ textbox : [ "placeholder" , "value "] ,
47
49
}
48
50
} ;
49
51
@@ -103,13 +105,13 @@ function overlayChildNodes(fromFragment, toElement) {
103
105
}
104
106
105
107
if ( childNode . hasAttribute ( "data-l10n-name" ) ) {
106
- const sanitized = namedChildFrom ( toElement , childNode ) ;
108
+ const sanitized = getNodeForNamedElement ( toElement , childNode ) ;
107
109
fromFragment . replaceChild ( sanitized , childNode ) ;
108
110
continue ;
109
111
}
110
112
111
113
if ( isElementAllowed ( childNode ) ) {
112
- const sanitized = allowedChild ( childNode ) ;
114
+ const sanitized = createSanitizedElement ( childNode ) ;
113
115
fromFragment . replaceChild ( sanitized , childNode ) ;
114
116
continue ;
115
117
}
@@ -121,7 +123,7 @@ function overlayChildNodes(fromFragment, toElement) {
121
123
) ;
122
124
123
125
// If all else fails, replace the element with its text content.
124
- fromFragment . replaceChild ( textNode ( childNode ) , childNode ) ;
126
+ fromFragment . replaceChild ( createTextNodeFromTextContent ( childNode ) , childNode ) ;
125
127
}
126
128
127
129
toElement . textContent = "" ;
@@ -193,7 +195,7 @@ function overlayAttributes(fromElement, toElement) {
193
195
* @returns {Element }
194
196
* @private
195
197
*/
196
- function namedChildFrom ( sourceElement , translatedChild ) {
198
+ function getNodeForNamedElement ( sourceElement , translatedChild ) {
197
199
const childName = translatedChild . getAttribute ( "data-l10n-name" ) ;
198
200
const sourceChild = sourceElement . querySelector (
199
201
`[data-l10n-name="${ childName } "]`
@@ -203,7 +205,7 @@ function namedChildFrom(sourceElement, translatedChild) {
203
205
console . warn (
204
206
`An element named "${ childName } " wasn't found in the source.`
205
207
) ;
206
- return textNode ( translatedChild ) ;
208
+ return createTextNodeFromTextContent ( translatedChild ) ;
207
209
}
208
210
209
211
if ( sourceChild . localName !== translatedChild . localName ) {
@@ -212,7 +214,7 @@ function namedChildFrom(sourceElement, translatedChild) {
212
214
`but its type ${ translatedChild . localName } didn't match the ` +
213
215
`element found in the source (${ sourceChild . localName } ).`
214
216
) ;
215
- return textNode ( translatedChild ) ;
217
+ return createTextNodeFromTextContent ( translatedChild ) ;
216
218
}
217
219
218
220
// Remove it from sourceElement so that the translation cannot use
@@ -239,7 +241,7 @@ function namedChildFrom(sourceElement, translatedChild) {
239
241
* @returns {Element }
240
242
* @private
241
243
*/
242
- function allowedChild ( element ) {
244
+ function createSanitizedElement ( element ) {
243
245
// Start with an empty element of the same type to remove nested children
244
246
// and non-localizable attributes defined by the translation.
245
247
const clone = element . ownerDocument . createElement ( element . localName ) ;
@@ -253,7 +255,7 @@ function allowedChild(element) {
253
255
* @returns {Node }
254
256
* @private
255
257
*/
256
- function textNode ( element ) {
258
+ function createTextNodeFromTextContent ( element ) {
257
259
return element . ownerDocument . createTextNode ( element . textContent ) ;
258
260
}
259
261
0 commit comments