@yuneta/gobj-js 7.16.5 → 7.16.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4944,7 +4944,13 @@ function refresh_language(element, t) {
4944
4944
  return;
4945
4945
  }
4946
4946
  if (!element) element = document;
4947
- element.querySelectorAll("[data-i18n]").forEach(function(elem) {
4947
+ const matching = (selector) => {
4948
+ let out = [];
4949
+ if (typeof element.matches === "function" && element.matches(selector)) out.push(element);
4950
+ out.push(...element.querySelectorAll(selector));
4951
+ return out;
4952
+ };
4953
+ matching("[data-i18n]").forEach(function(elem) {
4948
4954
  let value = elem.getAttribute("data-i18n");
4949
4955
  for (let node of elem.childNodes) if (node.nodeType === Node.TEXT_NODE) {
4950
4956
  if (!value) value = node.nodeValue;
@@ -4952,15 +4958,15 @@ function refresh_language(element, t) {
4952
4958
  break;
4953
4959
  }
4954
4960
  });
4955
- element.querySelectorAll("[data-i18n-title]").forEach(function(elem) {
4961
+ matching("[data-i18n-title]").forEach(function(elem) {
4956
4962
  let value = elem.getAttribute("data-i18n-title");
4957
4963
  if (value) elem.setAttribute("title", t(value));
4958
4964
  });
4959
- element.querySelectorAll("[data-i18n-aria-label]").forEach(function(elem) {
4965
+ matching("[data-i18n-aria-label]").forEach(function(elem) {
4960
4966
  let value = elem.getAttribute("data-i18n-aria-label");
4961
4967
  if (value) elem.setAttribute("aria-label", t(value));
4962
4968
  });
4963
- element.querySelectorAll("[data-i18n-placeholder]").forEach(function(elem) {
4969
+ matching("[data-i18n-placeholder]").forEach(function(elem) {
4964
4970
  let value = elem.getAttribute("data-i18n-placeholder");
4965
4971
  if (value) elem.setAttribute("placeholder", t(value));
4966
4972
  });