key2.html revision 08e054017132cdd838955bc0af15889f1f2a7b42
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
<html lang="en">
<head>
<title>Two Event Bugs</title>
<script type="text/javascript">
YUI.add('focusmanager', function(Y) {
var FocusManager = function () {
FocusManager.superclass.constructor.apply(this, arguments);
};
};
_onKeyDown1: function (event) {
console.log("_onKeyDown1 was called.");
},
initializer: function (config) {
this._node = config.owner;
var fn = function (event, arg1, arg2) {
console.log("Number of args: " + arguments.length);
console.log(this); // scope
console.log("Argument 1: " + arg1);
console.log("Argument 2: " + arg2);
}
Y.on("key", fn, "#link-1", "down:38", Y, "arg1", "arg2");
// BUG #1:
// The handler "_onKeyDown1" never gets called when "this"
// is passed as the scope
Y.on("key", this._onKeyDown1, this._node, "down:38,40", this);
// BUG #2:
// accessible to the callback
Y.on("key", function (event, arg1, arg2) {
console.log("Number of args: " + arguments.length);
console.log(this); // scope
console.log("Argument 1: " + arg1);
console.log("Argument 2: " + arg2);
}, this._node, "down:38,40", Y, "arg1", "arg2");
},
destructor: function () {
}
});
FocusManager.NAME = "focusManager";
FocusManager.NS = "focusManager";
Y.namespace("plugin");
Y.plugin.FocusManager = FocusManager;
}, '@VERSION@' );
</script>
</head>
<body>
<script type="text/javascript">
YUI().use("*", function(Y) {
var oNode = Y.Node.get("#link-1");
});
</script>
</body>
</html>