Files
tubestation/browser/extensions/formautofill/content/l10n.js
Matthew Noorenberghe 4dd71f263a Bug 1466720 - Don't reload l10n.js in the PaymentRequest scope on a refresh. r=sfoster
There was an error trying to redefine variables from l10n.js via loadSubScript. We really only need
it loaded once like a frame script but I had to fix the l10n.js code to handle this properly.

MozReview-Commit-ID: EbNrEaRQJbs
2018-06-11 00:03:47 -07:00

42 lines
1.3 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/**
* This file will be replaced by Fluent but it's a middle ground so we can share
* the edit dialog code with the unprivileged PaymentRequest dialog before the
* Fluent conversion
*/
/* global content */
ChromeUtils.import("resource://formautofill/FormAutofillUtils.jsm");
const CONTENT_WIN = typeof(window) != "undefined" ? window : this;
const L10N_ATTRIBUTES = ["data-localization", "data-localization-region"];
// eslint-disable-next-line mozilla/balanced-listeners
CONTENT_WIN.addEventListener("DOMContentLoaded", function onDCL(evt) {
let doc = evt.target;
FormAutofillUtils.localizeMarkup(doc);
let mutationObserver = new doc.ownerGlobal.MutationObserver(function onMutation(mutations) {
for (let mutation of mutations) {
if (!mutation.target.hasAttribute(mutation.attributeName)) {
// The attribute was removed in the meantime.
continue;
}
FormAutofillUtils.localizeAttributeForElement(mutation.target, mutation.attributeName);
}
});
mutationObserver.observe(doc, {
attributes: true,
attributeFilter: L10N_ATTRIBUTES,
subtree: true,
});
});