adding some more error trapping on the tree navigation primitives
This commit is contained in:
parent
2c44867618
commit
c91e2f2dbb
|
@ -1562,6 +1562,11 @@
|
||||||
var checkMockView = plt.baselib.check.makeCheckArgumentType(
|
var checkMockView = plt.baselib.check.makeCheckArgumentType(
|
||||||
isMockView, 'view');
|
isMockView, 'view');
|
||||||
|
|
||||||
|
var checkMockViewOnElement = plt.baselib.check.makeCheckArgumentType(
|
||||||
|
function(x) {
|
||||||
|
return isMockView(x) && (!(x.cursor.isOnAtomicElement()));
|
||||||
|
},
|
||||||
|
'element-focused view');
|
||||||
|
|
||||||
|
|
||||||
var checkSelector = plt.baselib.check.makeCheckArgumentType(
|
var checkSelector = plt.baselib.check.makeCheckArgumentType(
|
||||||
|
@ -1719,7 +1724,13 @@
|
||||||
1,
|
1,
|
||||||
function(MACHINE) {
|
function(MACHINE) {
|
||||||
var view = checkMockView(MACHINE, 'view-left', 0);
|
var view = checkMockView(MACHINE, 'view-left', 0);
|
||||||
return view.left();
|
try {
|
||||||
|
return view.left();
|
||||||
|
} catch (e) {
|
||||||
|
plt.baselib.exceptions.raise(
|
||||||
|
MACHINE,
|
||||||
|
new Error("unable to focus left"));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
EXPORTS['view-right'] = makePrimitiveProcedure(
|
EXPORTS['view-right'] = makePrimitiveProcedure(
|
||||||
|
@ -1727,7 +1738,13 @@
|
||||||
1,
|
1,
|
||||||
function(MACHINE) {
|
function(MACHINE) {
|
||||||
var view = checkMockView(MACHINE, 'view-right', 0);
|
var view = checkMockView(MACHINE, 'view-right', 0);
|
||||||
return view.right();
|
try {
|
||||||
|
return view.right();
|
||||||
|
} catch (e) {
|
||||||
|
plt.baselib.exceptions.raise(
|
||||||
|
MACHINE,
|
||||||
|
new Error("unable to focus right"));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
EXPORTS['view-up'] = makePrimitiveProcedure(
|
EXPORTS['view-up'] = makePrimitiveProcedure(
|
||||||
|
@ -1735,7 +1752,13 @@
|
||||||
1,
|
1,
|
||||||
function(MACHINE) {
|
function(MACHINE) {
|
||||||
var view = checkMockView(MACHINE, 'view-up', 0);
|
var view = checkMockView(MACHINE, 'view-up', 0);
|
||||||
return view.up();
|
try {
|
||||||
|
return view.up();
|
||||||
|
} catch (e) {
|
||||||
|
plt.baselib.exceptions.raise(
|
||||||
|
MACHINE,
|
||||||
|
new Error("unable to focus up"));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
EXPORTS['view-down'] = makePrimitiveProcedure(
|
EXPORTS['view-down'] = makePrimitiveProcedure(
|
||||||
|
@ -1743,7 +1766,13 @@
|
||||||
1,
|
1,
|
||||||
function(MACHINE) {
|
function(MACHINE) {
|
||||||
var view = checkMockView(MACHINE, 'view-down', 0);
|
var view = checkMockView(MACHINE, 'view-down', 0);
|
||||||
return view.down();
|
try {
|
||||||
|
return view.down();
|
||||||
|
} catch(e) {
|
||||||
|
plt.baselib.exceptions.raise(
|
||||||
|
MACHINE,
|
||||||
|
new Error("unable to focus down"));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
EXPORTS['view-forward'] = makePrimitiveProcedure(
|
EXPORTS['view-forward'] = makePrimitiveProcedure(
|
||||||
|
@ -1751,7 +1780,13 @@
|
||||||
1,
|
1,
|
||||||
function(MACHINE) {
|
function(MACHINE) {
|
||||||
var view = checkMockView(MACHINE, 'view-forward', 0);
|
var view = checkMockView(MACHINE, 'view-forward', 0);
|
||||||
return view.forward();
|
try {
|
||||||
|
return view.forward();
|
||||||
|
} catch(e) {
|
||||||
|
plt.baselib.exceptions.raise(
|
||||||
|
MACHINE,
|
||||||
|
new Error("unable to focus forward"));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
EXPORTS['view-backward'] = makePrimitiveProcedure(
|
EXPORTS['view-backward'] = makePrimitiveProcedure(
|
||||||
|
@ -1759,7 +1794,13 @@
|
||||||
1,
|
1,
|
||||||
function(MACHINE) {
|
function(MACHINE) {
|
||||||
var view = checkMockView(MACHINE, 'view-backward', 0);
|
var view = checkMockView(MACHINE, 'view-backward', 0);
|
||||||
return view.backward();
|
try {
|
||||||
|
return view.backward();
|
||||||
|
} catch(e) {
|
||||||
|
plt.baselib.exceptions.raise(
|
||||||
|
MACHINE,
|
||||||
|
new Error("unable to focus backward"));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -1946,7 +1987,7 @@
|
||||||
'view-append-child',
|
'view-append-child',
|
||||||
2,
|
2,
|
||||||
function(MACHINE) {
|
function(MACHINE) {
|
||||||
var view = checkMockView(MACHINE, 'view-append-child', 0);
|
var view = checkMockViewOnElement(MACHINE, 'view-append-child', 0);
|
||||||
var x = MACHINE.e[MACHINE.e.length - 2];
|
var x = MACHINE.e[MACHINE.e.length - 2];
|
||||||
PAUSE(function(restart) {
|
PAUSE(function(restart) {
|
||||||
coerseToDomNode(x,
|
coerseToDomNode(x,
|
||||||
|
|
|
@ -28,6 +28,10 @@ var TreeCursor = (function() {
|
||||||
this.atomicF = atomicF;
|
this.atomicF = atomicF;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TreeCursor.prototype.isOnAtomicElement = function() {
|
||||||
|
return this.atomicF(this.node);
|
||||||
|
};
|
||||||
|
|
||||||
TreeCursor.prototype.canDown = function() {
|
TreeCursor.prototype.canDown = function() {
|
||||||
return (!(this.atomicF(this.node)) &&
|
return (!(this.atomicF(this.node)) &&
|
||||||
this.openF(this.node).length !== 0);
|
this.openF(this.node).length !== 0);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user