docs(tests): explain input ownership and incremental query assertions
This commit is contained in:
@@ -11,6 +11,7 @@ test('gesture then tool then shortcut claim once; declining handlers fall throug
|
||||
|
||||
// 用伪closest模拟select和注册浮层,并传空/无效路径项,确认上下文识别不依赖全局Element。
|
||||
test('DOM input context recognizes registered overlays and native selects without browser globals',()=>{
|
||||
// closest 只识别测试关心的选择器,不实现真实祖先遍历;验证的是路由如何消费识别结果。
|
||||
const select={closest:selector=>selector.split(',').includes('select')?select:null};
|
||||
const overlay={closest:selector=>selector.includes('[data-canvas-overlay-view]')?overlay:null};
|
||||
assert.deepEqual(canvasKeyContext({target:select}),{textEditing:true,overlay:false});
|
||||
@@ -19,6 +20,7 @@ test('DOM input context recognizes registered overlays and native selects withou
|
||||
});
|
||||
// 事件target已被Shadow DOM重定向到host,composedPath仍含textarea;Escape必须留给内部文本而非取消画布手势。
|
||||
test('retargeted shadow events retain their inner text owner and never reach a gesture',()=>{
|
||||
// 输入元素放在路径首项而 target 指向 host,隔离事件重定向之后仍需识别内部编辑者的情况。
|
||||
const input={closest:selector=>selector.split(',').includes('textarea')?input:null},host={closest:()=>null};
|
||||
const context=canvasKeyContext({target:host,composedPath:()=>[input,host]});let canceled=false;
|
||||
assert.equal(routeCanvasKey({key:'Escape',...context},{gesture:()=>{canceled=true;return true;}}),'text');assert.equal(canceled,false);
|
||||
|
||||
Reference in New Issue
Block a user