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