@@ -23,7 +23,7 @@ const TEXT_LEVEL_ELEMENTS = {
2323
2424const LOCALIZABLE_ATTRIBUTES = {
2525 "http://www.w3.org/1999/xhtml" : {
26- global : [ "title" , "aria-label" , "aria-valuetext" , "aria-moz-hint" ] ,
26+ global : [ "title" , "aria-label" , "aria-valuetext" ] ,
2727 a : [ "download" ] ,
2828 area : [ "download" , "alt" ] ,
2929 // value is special-cased in isAttrNameLocalizable
@@ -39,11 +39,13 @@ const LOCALIZABLE_ATTRIBUTES = {
3939 } ,
4040 "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" : {
4141 global : [
42- "accesskey" , "aria-label" , "aria-valuetext" , "aria-moz-hint" , "label"
42+ "accesskey" , "aria-label" , "aria-valuetext" , "label" ,
43+ "title" , "tooltiptext"
4344 ] ,
45+ description : [ "value" ] ,
4446 key : [ "key" , "keycode" ] ,
45- textbox : [ "placeholder " ] ,
46- toolbarbutton : [ "tooltiptext " ] ,
47+ label : [ "value " ] ,
48+ textbox : [ "placeholder" , "value "] ,
4749 }
4850} ;
4951
@@ -103,13 +105,13 @@ function overlayChildNodes(fromFragment, toElement) {
103105 }
104106
105107 if ( childNode . hasAttribute ( "data-l10n-name" ) ) {
106- const sanitized = namedChildFrom ( toElement , childNode ) ;
108+ const sanitized = getNodeForNamedElement ( toElement , childNode ) ;
107109 fromFragment . replaceChild ( sanitized , childNode ) ;
108110 continue ;
109111 }
110112
111113 if ( isElementAllowed ( childNode ) ) {
112- const sanitized = allowedChild ( childNode ) ;
114+ const sanitized = createSanitizedElement ( childNode ) ;
113115 fromFragment . replaceChild ( sanitized , childNode ) ;
114116 continue ;
115117 }
@@ -121,7 +123,7 @@ function overlayChildNodes(fromFragment, toElement) {
121123 ) ;
122124
123125 // If all else fails, replace the element with its text content.
124- fromFragment . replaceChild ( textNode ( childNode ) , childNode ) ;
126+ fromFragment . replaceChild ( createTextNodeFromTextContent ( childNode ) , childNode ) ;
125127 }
126128
127129 toElement . textContent = "" ;
@@ -193,7 +195,7 @@ function overlayAttributes(fromElement, toElement) {
193195 * @returns {Element }
194196 * @private
195197 */
196- function namedChildFrom ( sourceElement , translatedChild ) {
198+ function getNodeForNamedElement ( sourceElement , translatedChild ) {
197199 const childName = translatedChild . getAttribute ( "data-l10n-name" ) ;
198200 const sourceChild = sourceElement . querySelector (
199201 `[data-l10n-name="${ childName } "]`
@@ -203,7 +205,7 @@ function namedChildFrom(sourceElement, translatedChild) {
203205 console . warn (
204206 `An element named "${ childName } " wasn't found in the source.`
205207 ) ;
206- return textNode ( translatedChild ) ;
208+ return createTextNodeFromTextContent ( translatedChild ) ;
207209 }
208210
209211 if ( sourceChild . localName !== translatedChild . localName ) {
@@ -212,7 +214,7 @@ function namedChildFrom(sourceElement, translatedChild) {
212214 `but its type ${ translatedChild . localName } didn't match the ` +
213215 `element found in the source (${ sourceChild . localName } ).`
214216 ) ;
215- return textNode ( translatedChild ) ;
217+ return createTextNodeFromTextContent ( translatedChild ) ;
216218 }
217219
218220 // Remove it from sourceElement so that the translation cannot use
@@ -239,7 +241,7 @@ function namedChildFrom(sourceElement, translatedChild) {
239241 * @returns {Element }
240242 * @private
241243 */
242- function allowedChild ( element ) {
244+ function createSanitizedElement ( element ) {
243245 // Start with an empty element of the same type to remove nested children
244246 // and non-localizable attributes defined by the translation.
245247 const clone = element . ownerDocument . createElement ( element . localName ) ;
@@ -253,7 +255,7 @@ function allowedChild(element) {
253255 * @returns {Node }
254256 * @private
255257 */
256- function textNode ( element ) {
258+ function createTextNodeFromTextContent ( element ) {
257259 return element . ownerDocument . createTextNode ( element . textContent ) ;
258260}
259261
0 commit comments