fixing bind on anonymous values.
This commit is contained in:
parent
c00a64d078
commit
5d24ac1af7
|
@ -23,7 +23,7 @@
|
||||||
;; until we're all done.
|
;; until we're all done.
|
||||||
(define (draw w v)
|
(define (draw w v)
|
||||||
(cond [(< w (length dwarf-names))
|
(cond [(< w (length dwarf-names))
|
||||||
(view-append-child (view-focus v "ul")
|
(view-append-child (view-focus v "#list")
|
||||||
(make-item (list-ref dwarf-names w)))]
|
(make-item (list-ref dwarf-names w)))]
|
||||||
[else
|
[else
|
||||||
v]))
|
v]))
|
||||||
|
@ -36,5 +36,5 @@
|
||||||
|
|
||||||
(big-bang 0
|
(big-bang 0
|
||||||
(initial-view index.html)
|
(initial-view index.html)
|
||||||
(on-tick tick 1)
|
(on-tick tick 10)
|
||||||
(to-draw draw))
|
(to-draw draw))
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<html>
|
<html>
|
||||||
<head><title>Dwarves</title></head>
|
<head><title>Dwarves</title></head>
|
||||||
<body>
|
<body>
|
||||||
<ul id="#list"></ul>
|
<h1>Dwarfs from Snow White</h1>
|
||||||
|
<ul id="list">
|
||||||
|
</ul>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -261,9 +261,8 @@
|
||||||
|
|
||||||
// HACK: every node that is bound needs to have an id. We
|
// HACK: every node that is bound needs to have an id. We
|
||||||
// enforce this by mutating the node.
|
// enforce this by mutating the node.
|
||||||
if ($(this.cursor.node).attr("id") === undefined) {
|
if (this.cursor.node.id === undefined) {
|
||||||
$(this.cursor.node).attr("id",
|
this.cursor.node.id = ("__webWorldId_" + mockViewIdGensym++);
|
||||||
("__webWorldId_" + mockViewIdGensym++));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.act(
|
return this.act(
|
||||||
|
@ -330,9 +329,9 @@
|
||||||
while (cursor.canRight()) {
|
while (cursor.canRight()) {
|
||||||
cursor = cursor.right();
|
cursor = cursor.right();
|
||||||
}
|
}
|
||||||
return cursor.insertRight(domNode);
|
return cursor.insertRight(domNode.cloneNode(true));
|
||||||
} else {
|
} else {
|
||||||
return cursor.insertDown(domNode);
|
return cursor.insertDown(domNode.cloneNode(true));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
function(eventHandlers) { return eventHandlers; },
|
function(eventHandlers) { return eventHandlers; },
|
||||||
|
@ -481,12 +480,12 @@
|
||||||
} catch (exn) {
|
} catch (exn) {
|
||||||
return onFail(exn);
|
return onFail(exn);
|
||||||
}
|
}
|
||||||
return onSuccess(dom);
|
return onSuccess(dom.get(0));
|
||||||
} else if (isMockView(x)) {
|
} else if (isMockView(x)) {
|
||||||
return onSuccess(x.cursor.top().node);
|
return onSuccess(x.cursor.top().node);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
dom = $(plt.baselib.format.toDomNode(x))
|
dom = plt.baselib.format.toDomNode(x);
|
||||||
} catch (exn) {
|
} catch (exn) {
|
||||||
return onFail(exn);
|
return onFail(exn);
|
||||||
}
|
}
|
||||||
|
@ -496,7 +495,7 @@
|
||||||
|
|
||||||
|
|
||||||
var isDomNode = function(x) {
|
var isDomNode = function(x) {
|
||||||
if (return x.hasOwnProperty(nodeType) &&
|
return (x.hasOwnProperty('nodeType') &&
|
||||||
x.nodeType === 1);
|
x.nodeType === 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1225,13 +1224,33 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EXPORTS['view-append-child'] = makePrimitiveProcedure(
|
EXPORTS['view-append-child'] = makeClosure(
|
||||||
'view-append-child',
|
'view-append-child',
|
||||||
2,
|
2,
|
||||||
function(MACHINE) {
|
function(MACHINE) {
|
||||||
var view = checkMockView(MACHINE, 'view-append-child', 1);
|
var view = checkMockView(MACHINE, 'view-append-child', 0);
|
||||||
var dom = coerseToDomNode(MACHINE.env[MACHINE.env.length - 2]);
|
var oldArgcount = MACHINE.argcount;
|
||||||
return view.appendChild(dom);
|
var x = MACHINE.env[MACHINE.env.length - 2];
|
||||||
|
PAUSE(function(restart) {
|
||||||
|
coerseToDomNode(x,
|
||||||
|
function(dom) {
|
||||||
|
restart(function(MACHINE) {
|
||||||
|
MACHINE.argcount = oldArgcount;
|
||||||
|
var updatedView = view.appendChild(dom);
|
||||||
|
finalizeClosureCall(MACHINE, updatedView);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
function(err) {
|
||||||
|
restart(function(MACHINE) {
|
||||||
|
plt.baselib.exceptions.raise(
|
||||||
|
MACHINE,
|
||||||
|
new Error(plt.baselib.format.format(
|
||||||
|
"unable to translate ~s to dom node: ~a",
|
||||||
|
[x, exn.message])));
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user