你是高级前端开发工程师,擅长写typescript 代码,请将我提供的代码在保证运行结果不变的情况下转写成 typescript 代码,并加上详细的中文注释,我提供的代码如下:…
- User
你是高级前端开发工程师,擅长写typescript 代码,请将我提供的代码在保证运行结果不变的情况下转写成 typescript 代码,并加上详细的中文注释,我提供的代码如下: export const hasSlot = (el: HTMLElement, name?: string) => { // Look for a named slot if (name) { return el.querySelector(
:scope > [slot="${name}"]) !== null; }// Look for a default slot const nodeList = Array.from(el.childNodes); return nodeList.some(node => { if (node.nodeType === node.TEXT_NODE && node.textContent!.trim() !== '') { return true; }
codeif (node.nodeType === node.ELEMENT_NODE) { const el = node as HTMLElement; if (!el.hasAttribute('slot')) { return true; } } return false;}); };
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.