TypeScript wed/domutil focusNode示例

说明

typescript wed/domutil focusnode示例是从最受好评的开源项目中提取的实现代码,你可以参考下面示例的使用方式。

编程语言: TypeScript

命名空间/包名称: wed/domutil

示例#1
文件: domutil-test.ts 项目: lddubeau/wed

 it("focuses text's parent", () => {
   const text = testPara.firstChild!;
   assert.equal(text.nodeType, Node.TEXT_NODE, "node type is text");
   assert.notEqual(text, text.ownerDocument.activeElement,
                   "text is not focused");
   domutil.focusNode(text);
   assert.equal(text.parentNode, text.ownerDocument.activeElement,
                "text's parent is focused");
 });

示例#2
文件: domutil-test.ts 项目: lddubeau/wed

 it("focuses an element", () => {
   const p = testPara;
   assert.notEqual(p, p.ownerDocument.activeElement, "p is not focused");
   domutil.focusNode(p);
   assert.equal(p, p.ownerDocument.activeElement, "p is focused");
 });

展开阅读全文