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