key2.html revision 08e054017132cdd838955bc0af15889f1f2a7b42
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Two Event Bugs</title>
<script src="/build/yui/yui-debug.js" type="text/javascript"></script>
<script src="/build/oop/oop.js" type="text/javascript"></script>
<script src="/build/event-custom/event-custom-debug.js" type="text/javascript"></script>
<script src="/build/event/event-debug.js" type="text/javascript"></script>
<script src="/build/dom/dom.js" type="text/javascript"></script>
<script src="/build/node/node.js" type="text/javascript"></script>
<script src="/build/attribute/attribute.js" type="text/javascript"></script>
<script src="/build/base/base.js" type="text/javascript"></script>
<script type="text/javascript">
YUI.add('focusmanager', function(Y) {
var FocusManager = function () {
FocusManager.superclass.constructor.apply(this, arguments);
};
FocusManager.ATTRS = {
};
Y.extend(FocusManager, Y.Base, {
_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:
// The the first argument ("arg1") is swallowed/is not
// 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>
<a href="http://www.yahoo.com" id="link-1">Yahoo!</a>
<script type="text/javascript">
YUI().use("*", function(Y) {
var oNode = Y.Node.get("#link-1");
oNode.plug(Y.plugin.FocusManager);
});
</script>
</body>
</html>