-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathtest.js
84 lines (69 loc) · 1.58 KB
/
test.js
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
var Bindings = require("./bindings");
var o = Bindings.defineBindings({
target: [1]
}, {
source: {"<->": "target.rangeContent()"}
});
assertEqual(o.source[0], 1);
var oldSource = o.source;
assertEqual(oldSource[0], 1);
o.source = [2];
assertEqual(oldSource[0], 1);
o.target.splice(0, 3, 3);
assertEqual(oldSource, o.source);
assertEqual(oldSource[0], 1);
assertEqual(o.source[0], 3);
/*
defineBinding:
descriptor = {
"<-": "a",
target: o,
parameters: undefined,
document: document,
components: undefined
cancel: bind(o, "b", descriptor)
}
bind (object, name, descriptor):
descriptor.target = o
descriptor.targetPath = "b"
source = o
sourcePath = "a"
sourceScope = new Scope(o)
targetScope = new Scope(o)
sourceSyntax = parse(sourcePath)
targetSyntax = parse(targetPath)
sourceSyntax
Object
args: Array[1]
0: Object
args: Array[2]
0: Object
type: "value"
1: Object
type: "literal"
value: "target"
length: 2
type: "property"
length: 1
type: "rangeContent"
targetSyntax
Object
args: Array[2]
0: Object
type: "value"
1: Object
type: "literal"
value: "source"
length: 2
type: "property"
bindOneWay(target, source, ...)
bindOneWay(source, target, ...) // if two-way
bindOneWay():
// rotate operators from target to source
[targetSyntax, sourceSyntax] = solve(targetSyntax, sourceSyntax)
observeSource = compileObserver(sourceSyntax)
compileBinder(targetSyntax)(observeSource, sourceScope, targetScope, ...)
*/
function assertEqual(x, y) {
console.log(x===y ? "* " : "x ", x, y);
}