Author: reebalazs
Date: Thu Oct 4 18:11:49 2007
New Revision: 47150
Modified:
kukit/kukit.js/trunk/doc/HISTORY.txt
kukit/kukit.js/trunk/kukit/kssparser.js
kukit/kukit.js/trunk/kukit/resourcedata.js
kukit/kukit.js/trunk/tests/test_kssparser.js
Log:
Merge from ree-binding-improvements branch:
Implement event binding based on the ids fetched
dynamically from the dom, by value providers.
The merge is partial, and complex because the
branches has diverged too much.
Modified: kukit/kukit.js/trunk/doc/HISTORY.txt
==============================================================================
--- kukit/kukit.js/trunk/doc/HISTORY.txt (original)
+++ kukit/kukit.js/trunk/doc/HISTORY.txt Thu Oct 4 18:11:49 2007
@@ -4,6 +4,12 @@
kukit.js - 1.4dev Unreleased
+ - ...
+
+ - Implement event binding based on the ids fetched
+ dynamically from the dom, by value providers.
+ [ree]
+
- Store some data on HTML nodes for FireKiss
[gotcha]
Modified: kukit/kukit.js/trunk/kukit/kssparser.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/kssparser.js (original)
+++ kukit/kukit.js/trunk/kukit/kssparser.js Thu Oct 4 18:11:49 2007
@@ -379,6 +379,7 @@
"(": 'new kukit.kssp.MethodArgs(this.cursor, kukit.kssp.openParent)'
});
kukit.kssp.PropValue.prototype.process = function() {
+ // Parse all tokens (including first and last)
var context = {'nextTokenIndex': 0};
this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment);
this.txt = '';
@@ -466,16 +467,64 @@
"\r": 'this.emitAndReturn()',
"\/\*": 'this.emitAndReturn()',
":": 'this.emitAndReturn()',
- "(": 'this.emitAndReturn(new kukit.kssp.MethodArgs(this.cursor,' +
- 'kukit.kssp.openParent))'
+ "(": '[new kukit.kssp.openParent(this.cursor), new
kukit.kssp.PropValue(this.cursor)]',
+ ")": 'this.emitAndReturn(new kukit.kssp.closeParent(this.cursor))'
});
kukit.kssp.EventValue.prototype.multiword_allowed = false;
-kukit.kssp.EventValue.prototype.process =
- kukit.kssp.PropValue.prototype.process;
-kukit.kssp.EventValue.prototype.valueClass = kukit.rd.KssPseudoValue;
+kukit.kssp.EventValue.prototype.process = function() {
+ // Parse all tokens (including first and last)
+ var context = {'nextTokenIndex': 0};
+ this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment);
+ this.txt = '';
+ var txt = context.txt;
+ if (this.notInTokens(context, kukit.kssp.String)) {
+ // The previous txt must be all whitespace.
+ if (txt) {
+;;; kukit.E = 'Wrong value : unallowed characters [' + txt + ']';
+;;; kukit.E += ' before a string.';
+ this.emitError(kukit.E);
+ }
+ // the next one must be a string.
+ this.expectToken(context, kukit.kssp.String);
+ this.produceTxt(context.token.txt);
+ } else if (this.notInTokens(context, kukit.kssp.openParent)) {
+ this.expectToken(context, kukit.kssp.openParent);
+ this.expectToken(context, kukit.kssp.PropValue);
+ this.value = new kukit.rd.KssEventValue(txt, context.token.value);
+ this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment);
+ // we have to be at the end and have no text after
+ if (context.txt) {
+;;; kukit.E = 'Wrong event selector : [' + context.txt;
+;;; kukit.E += '] is not expected before the closing';
+;;; kukit.E += ' parenthesis. :<EVENTNAME>(<ID>) can have';
+;;; kukit.E += ' only one parameter.';
+ this.emitError(kukit.E);
+ }
+ // eat up everything before the closing parent
+ this.expectToken(context, kukit.kssp.closeParent);
+ } else {
+ // not a string or method: check if we allowed multiword.
+ if (! this.multiword_allowed && txt.indexOf(' ') != -1) {
+;;; kukit.E = 'Wrong value : [' + txt + '] cannot have spaces.';
+ this.emitError(kukit.E);
+ }
+ this.produceTxt(txt);
+ }
+ // see what's after
+ if (context.nextTokenIndex < this.result.length) {
+ this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment);
+ // we have to be at the end and have no text after
+ if (context.nextTokenIndex < this.result.length || context.txt) {
+;;; kukit.E = 'Excess characters after the property value';
+ this.emitError(kukit.E);
+ }
+ }
+ this.result = [];
+};
+
kukit.kssp.EventValue.prototype.produceTxt = function(txt) {
// txt parms are returned embedded
- this.value = new kukit.rd.KssPseudoValue(txt, []);
+ this.value = new kukit.rd.KssEventValue(txt, null);
};
/*
@@ -647,8 +696,10 @@
* embedded parser to parse the selector
* KSS event selector: (has spaces in it)
* <css selector> selector:name(id)
-* KSS method selector: (has no spaces in it)
+* <css selector> selector:name(pprov(id))
+* kss method selector: (has no spaces in it)
* document:name(id) or behaviour:name(id)
+* document:name(pprov(id)) or behaviour:name(pprov(id))
*/
kukit.kssp.KssSelector = kukit.tk.mkParser('kssselector', {
":": '[new kukit.kssp.colon(this.cursor), new ' +
@@ -713,11 +764,6 @@
;;; kukit.E += ' event name cannot have spaces.';
this.emitError(kukit.E);
}
- if (pseudotoken.value.args.length > 1) {
-;;; kukit.E = 'Wrong event selector :';
-;;; kukit.E += ':<EVENTNAME>(<ID>) can have only one parameter.';
- this.emitError(kukit.E);
- }
css = this.cursor.text.substring(this.startpos, commatoken.startpos);
// Decide if we have an event or a method selector.
// We have a method selector if a single word "document" or "behaviour".
@@ -732,8 +778,18 @@
}
// create the selector.
var id = null;
- if (pseudotoken.value.args.length == 1) {
- id = pseudotoken.value.args[0];
+ var ppid = null;
+ if (pseudotoken.value.arg) {
+ // We have something in the parentheses after the event name.
+ if (pseudotoken.value.arg.isMethod) {
+ // we have a param provider here. Just store.
+ ppid = pseudotoken.value.arg;
+ // Check its syntax too.
+ ppid.check(kukit.pprovidersGlobalRegistry);
+ } else {
+ // just an id. Express in txt.
+ id = pseudotoken.value.arg.txt;
+ }
}
var name = pseudotoken.value.methodName;
var splitname = name.split('-');
@@ -750,7 +806,7 @@
// Protect the error for better logging
;;; try {
this.kssSelector = new kukit.rd.KssSelector(isEvent, css, name,
- namespace, id);
+ namespace, id, ppid);
;;; } catch(e) {
;;; if (e.name == 'KssSelectorError') {
;;; // Log the message
@@ -791,6 +847,7 @@
// Store event rules in the common list
for (var i=0; i<parser.eventRules.length; i++) {
var rule = parser.eventRules[i];
+ rule.kssSelector.prepareId();
this.rules.push(rule);
}
;;; } catch(e) {
Modified: kukit/kukit.js/trunk/kukit/resourcedata.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/resourcedata.js (original)
+++ kukit/kukit.js/trunk/kukit/resourcedata.js Thu Oct 4 18:11:49 2007
@@ -24,7 +24,7 @@
/*
* class KssSelector
*/
-kukit.rd.KssSelector = function(isEvent, css, name, namespace, id) {
+kukit.rd.KssSelector = function(isEvent, css, name, namespace, id, ppid) {
this.isEventSelector = isEvent;
this.isMethodSelector = ! isEvent;
// XXX GC row and column are wrong...
@@ -53,17 +53,27 @@
;;; msg = msg + '] must have one of the allowed names.';
;;; throw kukit.err.kssSelectorError(msg);
;;; }
+;;; if (ppid) {
+;;; var msg = 'KssSpecialSelector [' + name + '] must not stand ';
+;;; msg += 'with an event id acquired by parameter provider ['
+;;; msg += ppid.methodName + ']';
+;;; throw new kukit.err.KssSelectorError(msg);
+;;; }
;;; }
this.css = css;
this.name = name;
this.namespace = namespace;
this.className = null;
this.id = id;
+ this.ppid = ppid;
// finish up the KSS on it
- this.setIdAndClass();
+ // XXX We should not have this here, because this disables testing the
parser
+ // standalone, without a plugin registry. Original behaviour
+ // should be reverted instead.
+ this.setClassName();
};
-kukit.rd.KssSelector.prototype.setIdAndClass = function() {
+kukit.rd.KssSelector.prototype.setClassName = function() {
// Sets up id and class on the selector, based on registration info
// XXX GC instead of relying on exceptions, test if key exists
try {
@@ -72,14 +82,56 @@
} catch(e) {
throw kukit.err.parsingError(e.message);
}
+};
+
+kukit.rd.KssSelector.prototype.prepareId = function() {
+ if (this.ppid == null) {
+ if (this.id == null && this.ppid == null) {
+ // singleton for class
+ this.id = kukit.er.makeId(this.namespace, this.className);
+ }
+ // Also set the merge id. The rules with the same merge
+ // id should be merged on the same node.
+ this.mergeId = kukit.er.makeMergeId(this.id, this.namespace,
this.name);
+ }
+};
+
+kukit.rd.KssSelector.prototype.getId = function(node) {
+ // Gives the id depending on a node.
+ if (this.id) {
+ // Statically set.
+ return this.id;
+ } else {
+ // Evaluate it.
+ var id = this.ppid.pprovider.eval(this.ppid.args, node, {});
+ // check that the id is not empty or null!
+ if (! id) {
+;;; var namestr;
+;;; if (this.namespace) {
+;;; namestr = this.namespace + '-' + this.name;
+;;; } else {
+;;; namestr = this.name;
+;;; }
+;;; kukit.E = 'Did not get a valid state id, when evaluated';
+;;; kukit.E += ' the value provider [' + this.ppid.methodName + ']';
+;;; kukit.E += ' in kss selector [' + namestr + ']';
+;;; kukit.E += ' css=[' + this.css + ']';
+;;; throw kukit.E;
+ }
+ return id;
+ }
+};
- if (this.id == null) {
- // singleton for class
- this.id = kukit.er.makeId(this.namespace, this.className);
- }
- // Also set the merge id. The rules with the same merge
- // id should be merged on the same node.
- this.mergeId = kukit.er.makeMergeId(this.id, this.namespace, this.name);
+kukit.rd.KssSelector.prototype.getMergeId = function(node) {
+ // Gives the merge id depending on a node.
+ if (this.mergeId) {
+ // Statically set.
+ return this.mergeId;
+ } else {
+ // Evaluate it.
+ var id = this.getId(node);
+ this.mergeId = kukit.er.makeMergeId(id, this.namespace, this.name);
+ }
};
/*
@@ -165,18 +217,21 @@
};
/*
-* class KssPseudoValue
+* class KssEventValue
*/
-kukit.rd.KssPseudoValue = function(methodName, args) {
+kukit.rd.KssEventValue = function(methodName, arg) {
// A method parameter in the format
- // methodName(v1)
+ // methodname(v1)
+ // can be also:
+ // methodname(methodname2(v2))
+ // in both cases, arg is KssTextValue, or KssMethodValue
this.methodName = methodName;
- this.args = args;
+ this.arg = arg;
};
-kukit.rd.KssPseudoValue.prototype.isMethod = true;
+kukit.rd.KssEventValue.prototype.isMethod = true;
-kukit.rd.KssPseudoValue.prototype.check = function() {
+kukit.rd.KssEventValue.prototype.check = function() {
};
kukit.rd.EventRuleNr = 0; // just a counter
@@ -251,7 +306,9 @@
}
};
-kukit.rd.EventRule.prototype.getBinderInfo = function() {
+kukit.rd.EventRule.prototype.getBinderInfo = function(node) {
+ // Figure out what will be the "state id" for the kss event rule.
+ var id = this.kssSelector.getId(node);
// Gets the event instance for the rule.
return kukit.engine.binderInfoRegistry.getOrCreateBinderInfo(
this.kssSelector.id, this.kssSelector.className,
@@ -273,7 +330,7 @@
this.store(node);
// Creation of the binding oper
var oper = new kukit.op.Oper();
- var binderInfo = this.getBinderInfo();
+ var binderInfo = this.getBinderInfo(node);
oper.node = node;
oper.eventRule = this;
oper.binder = binderInfo.binder;
@@ -337,7 +394,7 @@
;;; }
};
-kukit.rd.EventRule.prototype.mergeIntoDict = function(dict, key, eventRule) {
+kukit.rd.EventRule.prototype.mergeIntoDict = function(dict, key) {
// Merge into the given dictionary by given key.
// If possible, store the genuine rule first - if not,
// clone it and do a merge. Never destroy the genuine
@@ -345,7 +402,7 @@
var mergedRule = dict[key];
if (typeof(mergedRule) == 'undefined') {
// there was no rule
- dict[key] = eventRule;
+ dict[key] = this;
} else {
// we have to merge the rule
if (! mergedRule.isMerged()) {
@@ -353,7 +410,7 @@
mergedRule = mergedRule.cloneForMerge();
dict[key] = mergedRule;
}
- mergedRule.merge(eventRule);
+ mergedRule.merge(this);
}
};
@@ -676,7 +733,7 @@
}
// Merge into the dict
eventRule.mergeIntoDict(
- nodeval.val, eventRule.kssSelector.mergeId, eventRule);
+ nodeval.val, eventRule.kssSelector.getMergeId(node));
};
kukit.rd.RuleTable.prototype.bindall = function(phase) {
@@ -744,7 +801,8 @@
;;; throw new Error('Unknown method rule category [' + category + '].');
;;; }
// Merge into the corresponding category
- eventRule.mergeIntoDict(dict, eventRule.kssSelector.mergeId, eventRule);
+ // mergeId must be set on kss selector already.
+ eventRule.mergeIntoDict(dict, eventRule.kssSelector.getMergeId());
};
kukit.rd.MethodTable.prototype.getMergedRule =
Modified: kukit/kukit.js/trunk/tests/test_kssparser.js
==============================================================================
--- kukit/kukit.js/trunk/tests/test_kssparser.js (original)
+++ kukit/kukit.js/trunk/tests/test_kssparser.js Thu Oct 4 18:11:49 2007
@@ -1,8 +1,6 @@
/*
-* Copyright (c) 2005-2006
-* Authors:
-* Martin Heidegger <[EMAIL PROTECTED]>
-* Balazs Ree <[EMAIL PROTECTED]>
+* Copyright (c) 2005-2007
+* Authors: KSS Project Contributors (see docs/CREDITS.txt)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as published
@@ -230,7 +228,7 @@
};
this.testEventValue = function() {
- // Parsing prop values in pseudo (no methods allowed)
+ // Parsing event value (now methods allowed too)
var txt= "b";
var cursor = new kukit.tk.Cursor(txt);
@@ -268,7 +266,8 @@
parser = new kukit.kssp.EventValue(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.value.methodName, 'click');
- this.assertListEquals(parser.value.args, ['x']);
+ this.assertEquals(parser.value.arg.isMethod, false);
+ this.assertEquals(parser.value.arg.txt, 'x');
// more then 1 args not ok (but we check it only from kss selector)
//txt= "drag(x, y)";
@@ -282,6 +281,28 @@
};
+ this.testEventValueWithValueProvider = function() {
+ // methods ok
+ txt= "click(kssAttr(x))";
+ src = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.EventValue(src, null, true);
+ this.assertEquals(parser.finished, true);
+ this.assertEquals(parser.value.methodName, 'click');
+ this.assertEquals(parser.value.arg.isMethod, true);
+ this.assertEquals(parser.value.arg.methodName, 'kssAttr');
+ this.assertListEquals(parser.value.arg.args, ['x']);
+ };
+
+ this.testEventValueWithValueProviderRejectsAccessValues = function() {
+ // no more values in the method
+ txt= "click(kssAttr(x), aaa)";
+ src = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.EventValue, src, null, true,
+ 'Wrong event selector : [,] is not expected before the closing
parenthesis. :<EVENTNAME>(<ID>) can have only one parameter.', 000);
+
+ // XXX add more failing cases, maybe?
+ };
+
this.testMethodArgs = function() {
// Parsing method args
var txt= "(a, b)";
@@ -419,6 +440,9 @@
+"#calendar-previous a:click {\n"
+" action-server : kukitGetPreviousMonth /* place comment
here*/;\n"
+" kukitGetPreviousMonth-member: formVar(edit, kssAttr(foo));\n"
+ +'}\n'
+ +"#button-one:click(kssAttr(widannoy)) {\n"
+ +" action-client: alert;\n"
+"}\n";
var cursor = new kukit.tk.Cursor(txt);
@@ -427,13 +451,13 @@
var parser = new kukit.kssp.Document(cursor, null, true);
this.assertEquals(parser.finished, true);
- this.assertEquals(parser.eventRules.length, 13);
+ this.assertEquals(parser.eventRules.length, 14);
var rule;
var action;
// rule 0
// #calendar-previous a:click {
- // kss-action : kukitresponse/kukitGetPreviousMonth;
+ // action-server : kukitresponse/kukitGetPreviousMonth;
// }
rule = parser.eventRules[0];
this.assertDictEquals(rule.parms, {});
@@ -451,7 +475,7 @@
// div#update-area:timeout {
// evt-timeout-delay: 2000;
// effect: fade;
- // kss-action: getCurrentTime;
+ // action-server: getCurrentTime;
// }
rule = parser.eventRules[1];
this.assertDictEquals(rule.parms, {'delay': '2000'});
@@ -469,7 +493,7 @@
// rule 2
// #calendar-previous a:click {
- // kss-action : 'kukitresponse/kukitGetPreviousMonth' /* place
comment here*/;
+ // action-server : 'kukitresponse/kukitGetPreviousMonth' /*
place comment here*/;
// }
rule = parser.eventRules[2];
this.assertDictEquals(rule.parms, {});
@@ -485,7 +509,7 @@
// rule 3
// #calendar-previous a:click {
- // kss-action : 'kukitresponse/kukitGetPreviousMonth' /* place
comment here*/;
+ // action-server : 'kukitresponse/kukitGetPreviousMonth' /*
place comment here*/;
// member: formVar(edit, 'f_member');
// }
rule = parser.eventRules[3];
@@ -504,7 +528,7 @@
// rule 4
// #calendar-previous a:dnd-drag(shelve) {
- // kss-action : whatever
+ // action-server : whatever
// }
rule = parser.eventRules[4];
this.assertDictEquals(rule.parms, {});
@@ -522,7 +546,7 @@
// rule 5
//#button-one:dnd-drag(annoyMe) {
- // kss-action: clickedButton;
+ // action-server: clickedButton;
// id: nodeAttr(id);
//}
rule = parser.eventRules[5];
@@ -542,7 +566,7 @@
// rule 6
// document:dnd-drag(annoyMe) {
- // kss-action: alert;
+ // action-client: alert;
// message: "You are an idiot! Ha ha ha. (But just keep on
trying...)";
//}
rule = parser.eventRules[6];
@@ -562,8 +586,7 @@
// rule 7
// document:dnd-drag(annoyMe) {
- // annoy#annoy-me {
- // kss-action: alert;
+ // action-client: alert;
// message: "You are an idiot! Ha ha ha. (But just keep on
trying...)";
//}
rule = parser.eventRules[7];
@@ -631,7 +654,6 @@
// setStyle-name: backgroundColor;
// setStyle-value: #FFa0a0;
//}
-
rule = parser.eventRules[10];
this.assertDictEquals(rule.parms, {});
this.assertEquals(rule.kssSelector.isEventSelector, true);
@@ -649,14 +671,13 @@
'kssSelector': new kukit.rd.KssMethodValue('htmlid',
['button_2'])
});
- // rule 12
+ // rule 11
//#button_3:click {
// action-client: setStyle;
// setStyle-kssSelector: "#button_4";
// setStyle-name: backgroundColor;
// setStyle-value: #FFa0a0;
//}\n";
-
rule = parser.eventRules[11];
this.assertDictEquals(rule.parms, {});
this.assertEquals(rule.kssSelector.isEventSelector, true);
@@ -674,7 +695,7 @@
'kssSelector': new kukit.rd.KssTextValue('#button_4')
});
- // rule 13
+ // rule 12
// #calendar-previous a:click {
// kss-action : 'kukitresponse/kukitGetPreviousMonth' /* place
comment here*/;
// member: formVar(edit, kssAttr(foo));
@@ -695,9 +716,31 @@
var kssAttr = formVar.args[1];
this.assertEquals(kssAttr.methodName, 'kssAttr');
this.assertListEquals(kssAttr.args, ['foo']);
+
+ // rule 13
+ // #button-one:click(kssAttr(widannoy)) {\n"
+ // action-client: alert;
+ //}
+ rule = parser.eventRules[13];
+ this.assertDictEquals(rule.parms, {});
+ this.assertEquals(rule.kssSelector.css, '#button-one');
+ this.assertEquals(rule.kssSelector.isEventSelector, true);
+ this.assertEquals(rule.kssSelector.name, 'click');
+ this.assertEquals(rule.kssSelector.namespace, null);
+ this.assertEquals(rule.kssSelector.id, null);
+ this.assertEquals(rule.kssSelector.ppid.methodName, 'kssAttr');
+ this.assertListEquals(rule.kssSelector.ppid.args, ['widannoy']);
+ action = rule.actions.content['alert'];
+ this.assertEquals(action.type, 'C');
+ this.assertEquals(action.name, 'alert');
+ this.assertEquals(action.error, null);
+ this.assertKssParmEquals(action.parms, {
+ });
+
};
this.testActionErrorParameters = function() {
+
var txt= ""
+"/* a long\n"
+"** comment\n"
@@ -850,7 +893,7 @@
txt= "a:click('hello', bello)";
cursor = new kukit.tk.Cursor(txt);
this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true,
- 'Wrong event selector ::<EVENTNAME>(<ID>) can have only one
parameter.', 22);
+ 'Wrong event selector : [,] is not expected before the closing
parenthesis. :<EVENTNAME>(<ID>) can have only one parameter.', 22);
// zero params: not std css but tolerated
txt= "a:click()";
@@ -904,22 +947,23 @@
'Wrong event selector : missing event qualifier :<EVENTNAME> or
:<EVENTNAME>(<ID>).', 20);
// Spaces in the end
- txt= " a:lang(hu, uh) b:click ";
+ // txt= " a:lang(hu, uh) b:click "; // XXX not supported
+ txt= " a:lang(hu-uh) b:click ";
cursor = new kukit.tk.Cursor(txt);
parser = new kukit.kssp.KssSelector(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.kssSelector.isEventSelector, true);
- this.assertEquals(parser.kssSelector.css, " a:lang(hu, uh) b");
+ this.assertEquals(parser.kssSelector.css, " a:lang(hu-uh) b");
this.assertEquals(parser.kssSelector.name, 'click');
this.assertEquals(parser.kssSelector.namespace, null);
// Comment in the end
- txt= " a:lang(hu, uh) b:click/*comment here*/";
+ txt= " a:lang(hu-uh) b:click/*comment here*/";
cursor = new kukit.tk.Cursor(txt);
parser = new kukit.kssp.KssSelector(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.kssSelector.isEventSelector, true);
- this.assertEquals(parser.kssSelector.css, " a:lang(hu, uh) b");
+ this.assertEquals(parser.kssSelector.css, " a:lang(hu-uh) b");
this.assertEquals(parser.kssSelector.name, 'click');
this.assertEquals(parser.kssSelector.namespace, null);
@@ -1382,6 +1426,43 @@
'Wrong value for evt-[<NAMESPACE>-]<EVENTNAME>
[dnd-drag] : <NAMESPACE>-<EVENTNAME> should exist in the event of the
selectors.', 6);
}
+ this.testValueProvidersInEventIdentification = function() {
+ // Param providers within the event identification
+
+ var txt= "a:click(kssAttr(hello))";
+ var src = new kukit.tk.Cursor(txt);
+ var parser = new kukit.kssp.KssSelector(src, null, true);
+ this.assertEquals(parser.finished, true);
+ this.assertEquals(parser.kssSelector.isEventSelector, true);
+ this.assertEquals(parser.kssSelector.css, 'a');
+ this.assertEquals(parser.kssSelector.name, 'click');
+ this.assertEquals(parser.kssSelector.namespace, null);
+ this.assertEquals(parser.kssSelector.id, null);
+ this.assertEquals(parser.kssSelector.ppid.methodName, 'kssAttr');
+ this.assertListEquals(parser.kssSelector.ppid.args, ['hello']);
+ };
+
+ this.testValueProvidersInEventIdentification2 = function() {
+ var txt= "a:click(kssAttr(hello, true ))";
+ var src = new kukit.tk.Cursor(txt);
+ var parser = new kukit.kssp.KssSelector(src, null, true);
+ this.assertEquals(parser.finished, true);
+ this.assertEquals(parser.kssSelector.isEventSelector, true);
+ this.assertEquals(parser.kssSelector.css, 'a');
+ this.assertEquals(parser.kssSelector.name, 'click');
+ this.assertEquals(parser.kssSelector.namespace, null);
+ this.assertEquals(parser.kssSelector.id, null);
+ this.assertEquals(parser.kssSelector.ppid.methodName, 'kssAttr');
+ this.assertListEquals(parser.kssSelector.ppid.args, ['hello', 'true']);
+ };
+
+ this.testValueProvidersInEventIdentificationRejectsMoreParameters =
function() {
+ var txt= "a:drag(kssAttr(hello), xxx)";
+ var src = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.KssSelector, src, null, true,
+ 'Wrong event selector : [,] is not expected before the closing
parenthesis. :<EVENTNAME>(<ID>) can have only one parameter.', 000);
+ };
+
};
kukit.KssParserSelectorsTestCase.prototype = new kukit.KssParserTestCaseBase;
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins