-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-click.js
More file actions
64 lines (53 loc) · 2.29 KB
/
debug-click.js
File metadata and controls
64 lines (53 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Simple debug test to understand click function behavior
import { watch, click, getCurrentContext } from './src/index.js';
console.log('=== Debug Test: Click Function Behavior ===');
// Test 1: What does click return outside of generator context?
console.log('\n1. Testing click outside generator context:');
try {
const result = click(() => console.log('handler'));
console.log('click() returned:', typeof result, result);
console.log('Is iterable?', result && typeof result[Symbol.iterator] === 'function');
console.log('Is generator?', result && typeof result.next === 'function');
} catch (error) {
console.log('Error calling click():', error.message);
}
// Test 2: What does getCurrentContext return outside generator?
console.log('\n2. Testing getCurrentContext outside generator:');
try {
const context = getCurrentContext();
console.log('getCurrentContext() returned:', context);
} catch (error) {
console.log('Error calling getCurrentContext():', error.message);
}
// Test 3: What does click return inside generator context?
console.log('\n3. Testing click inside generator context:');
const button = document.createElement('button');
document.body.appendChild(button);
watch(button, function* () {
console.log('Inside generator function');
// Check context
const context = getCurrentContext();
console.log('Context inside generator:', !!context);
// Test click function
try {
const result = click(() => console.log('handler'));
console.log('click() returned inside generator:', typeof result, result);
console.log('Is iterable?', result && typeof result[Symbol.iterator] === 'function');
console.log('Is generator?', result && typeof result.next === 'function');
// Try to iterate if it's iterable
if (result && typeof result[Symbol.iterator] === 'function') {
console.log('Attempting to iterate...');
const iterator = result[Symbol.iterator]();
const firstNext = iterator.next();
console.log('First next():', firstNext);
}
// Try yield* to see what happens
console.log('Attempting yield*...');
yield* result;
console.log('yield* succeeded!');
} catch (error) {
console.log('Error with click in generator:', error.message);
console.log('Error stack:', error.stack);
}
});
console.log('\n=== Debug Test Complete ===');