@whitesev/domutils 1.4.0 → 1.4.2

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.
package/dist/index.amd.js CHANGED
@@ -935,8 +935,8 @@ define((function () { 'use strict';
935
935
  return $ele?.innerHTML?.trim() === "";
936
936
  });
937
937
  }
938
- else if (selector.match(/[^\s]{1}:contains\("(.*)"\)$/gi) ||
939
- selector.match(/[^\s]{1}:contains\('(.*)'\)$/gi)) {
938
+ else if (selector.match(/[^\s]{1}:contains\("(.*)"\)$/i) ||
939
+ selector.match(/[^\s]{1}:contains\('(.*)'\)$/i)) {
940
940
  // contains 语法
941
941
  let textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
942
942
  let text = textMatch[2];
@@ -946,12 +946,18 @@ define((function () { 'use strict';
946
946
  return ($ele?.textContent || $ele?.innerText)?.includes(text);
947
947
  });
948
948
  }
949
- else if (selector.match(/[^\s]{1}:regexp\("(.*)"\)$/gi) ||
950
- selector.match(/[^\s]{1}:regexp\('(.*)'\)$/gi)) {
949
+ else if (selector.match(/[^\s]{1}:regexp\("(.*)"\)$/i) ||
950
+ selector.match(/[^\s]{1}:regexp\('(.*)'\)$/i)) {
951
951
  // regexp 语法
952
952
  let textMatch = selector.match(/:regexp\(("|')(.*)("|')\)$/i);
953
- let text = textMatch[2];
954
- let regexp = new RegExp(text);
953
+ let pattern = textMatch[2];
954
+ let flagMatch = pattern.match(/("|'),[\s]*("|')([igm]{0,3})$/i);
955
+ let flags = "";
956
+ if (flagMatch) {
957
+ pattern = pattern.replace(/("|'),[\s]*("|')([igm]{0,3})$/gi, "");
958
+ flags = flagMatch[3];
959
+ }
960
+ let regexp = new RegExp(pattern, flags);
955
961
  selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
956
962
  return Array.from(context.windowApi.document.querySelectorAll(selector)).filter(($ele) => {
957
963
  // @ts-ignore