MCPcopy Create free account
hub / github.com/Xu22Web/tech-study-js / $_

Function $_

tech-study.js:1946–1964  ·  view source on GitHub ↗

* @description 异步选择器 * @param selector * @returns

(selector, parent = document, timeout)

Source from the content-addressed store, hash-verified

1944 * @returns
1945 */
1946function $_(selector, parent = document, timeout) {
1947 return new Promise((resolve) => {
1948 const timer = setInterval(() => {
1949 const selectors = Array.from(parent.querySelectorAll(selector));
1950 // 存在元素
1951 if (selectors.length) {
1952 clearInterval(timer);
1953 resolve(selectors);
1954 }
1955 }, 10);
1956 // 超时
1957 if (timeout) {
1958 setTimeout(() => {
1959 clearInterval(timer);
1960 resolve([]);
1961 }, timeout);
1962 }
1963 });
1964}
1965/**
1966 * @description 创建元素块
1967 * @param eles

Callers 5

renderExamBtnFunction · 0.70
handleSlideVerifyFunction · 0.70
openFrameFunction · 0.70
handleNewsFunction · 0.70
handleVideoFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected