@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.
@@ -4945,7 +4945,13 @@ function refresh_language(element, t) {
4945
4945
  return;
4946
4946
  }
4947
4947
  if (!element) element = document;
4948
- element.querySelectorAll("[data-i18n]").forEach(function(elem) {
4948
+ const matching = (selector) => {
4949
+ let out = [];
4950
+ if (typeof element.matches === "function" && element.matches(selector)) out.push(element);
4951
+ out.push(...element.querySelectorAll(selector));
4952
+ return out;
4953
+ };
4954
+ matching("[data-i18n]").forEach(function(elem) {
4949
4955
  let value = elem.getAttribute("data-i18n");
4950
4956
  for (let node of elem.childNodes) if (node.nodeType === Node.TEXT_NODE) {
4951
4957
  if (!value) value = node.nodeValue;
@@ -4953,15 +4959,15 @@ function refresh_language(element, t) {
4953
4959
  break;
4954
4960
  }
4955
4961
  });
4956
- element.querySelectorAll("[data-i18n-title]").forEach(function(elem) {
4962
+ matching("[data-i18n-title]").forEach(function(elem) {
4957
4963
  let value = elem.getAttribute("data-i18n-title");
4958
4964
  if (value) elem.setAttribute("title", t(value));
4959
4965
  });
4960
- element.querySelectorAll("[data-i18n-aria-label]").forEach(function(elem) {
4966
+ matching("[data-i18n-aria-label]").forEach(function(elem) {
4961
4967
  let value = elem.getAttribute("data-i18n-aria-label");
4962
4968
  if (value) elem.setAttribute("aria-label", t(value));
4963
4969
  });
4964
- element.querySelectorAll("[data-i18n-placeholder]").forEach(function(elem) {
4970
+ matching("[data-i18n-placeholder]").forEach(function(elem) {
4965
4971
  let value = elem.getAttribute("data-i18n-placeholder");
4966
4972
  if (value) elem.setAttribute("placeholder", t(value));
4967
4973
  });