[mochikit] Re: Bugfixes in Selector, DOM

2007-02-07 Thread Arnar Birgisson

On 2/7/07, Aaron Faanes <[EMAIL PROTECTED]> wrote:
>
> Oops, I meant Format.strip, not trim. There's just a couple places
> where:
>
> expression.replace(/(^\s+|\s+$)/g, '')

These are leftovers from the Prototype selectors, which
MochiKit.Selector was initially ported from. This may actually be a
little bit faster thatn Format.strip since strip calls lstrip and
rstrip and each of those do their own type checking and regex stuff.

I haven't made a very heavy use of Selector myself but I suspect that
for much use and large/complex documents it will need any
optimizations it can get. If someone can provide me with a hairy usage
example I'd be more than willing to spend some time speeding things
up.

Arnar

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~--~~~~--~~--~--~---



[mochikit] Re: Bugfixes in Selector, DOM

2007-02-07 Thread Aaron Faanes

Oops, I meant Format.strip, not trim. There's just a couple places
where:

expression.replace(/(^\s+|\s+$)/g, '')

is used where strip could be used. I'm not sure why I brought it up
now. :P

Thanks anyway. :)

 - Aaron

On Feb 7, 5:38 am, "Thomas Hervé" <[EMAIL PROTECTED]> wrote:
> On 7 fév, 11:44, "Aaron Faanes" <[EMAIL PROTECTED]> wrote:
>
> > The following is a couple bugfixes in Selector (just some unqualified
> > names that have been lurking)
>
> OK corrected.
>
> > There's also a few times in Selector where MochiKit.Format.trim could
> > be used, but isn't. It's not too big a deal, but it seems like if it's
> > already in MochiKit, it should be used in MochiKit.
>
> Actually Format.trim doesn't exist, so it'd be hard to use :).
>
> > Also a minor addition to DOM renames since IE blows and doesn't
> > recognize cellspacing.
>
> That seemed good, I added it.
>
> Thanks!
>
> --
> Thomas


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~--~~~~--~~--~--~---



[mochikit] Re: Convert more-dimensional associative object to an Array?

2007-02-07 Thread Johnny Blonde

Are you going to add this to the 1.4 version? Or should i just apply
it to my local installation?

Frank


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~--~~~~--~~--~--~---



[mochikit] Re: Convert more-dimensional associative object to an Array?

2007-02-07 Thread Arnar Birgisson

There is already a patch for this in Trac:
http://trac.mochikit.com/ticket/221

Arnar

On 2/7/07, Bob Ippolito <[EMAIL PROTECTED]> wrote:
>
> We definitely won't be extending itemgetter to do two entirely
> different things based upon the argument passed. However, we could
> create a differently named function (e.g. "rowgetter" or something of
> that sort) that does that.
>
> -bob
>
> On 2/7/07, Johnny Blonde <[EMAIL PROTECTED]> wrote:
> >
> > One more thing,
> >
> > is it now planned to extend itemgetter in order to accept an array
> > with the returning-order needed as mentioned by Arnar in its previous
> > post?
> >
> > Regards, Frank
> >
> >
> > >
> >
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~--~~~~--~~--~--~---



[mochikit] Re: Convert more-dimensional associative object to an Array?

2007-02-07 Thread Bob Ippolito

We definitely won't be extending itemgetter to do two entirely
different things based upon the argument passed. However, we could
create a differently named function (e.g. "rowgetter" or something of
that sort) that does that.

-bob

On 2/7/07, Johnny Blonde <[EMAIL PROTECTED]> wrote:
>
> One more thing,
>
> is it now planned to extend itemgetter in order to accept an array
> with the returning-order needed as mentioned by Arnar in its previous
> post?
>
> Regards, Frank
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~--~~~~--~~--~--~---



[mochikit] Re: Convert more-dimensional associative object to an Array?

2007-02-07 Thread Johnny Blonde

One more thing,

is it now planned to extend itemgetter in order to accept an array
with the returning-order needed as mentioned by Arnar in its previous
post?

Regards, Frank


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~--~~~~--~~--~--~---



[mochikit] Re: Convert more-dimensional associative object to an Array?

2007-02-07 Thread Johnny Blonde

Hello Arnar and folks.

Sorry for the late response, but i finally had the chance to spend
some days off in the snow with skiing.

Thanks a lot for your suggestions!

This did help me a lot!

I hope that with some more experience i can get way deeper in
MochiKit.

Regards, Frank



On 27 Jan., 04:12, "Arnar Birgisson" <[EMAIL PROTECTED]> wrote:
> On 1/27/07, Tom W.M. <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
>
>
> > >>> var dataArr = new Array();
> > >>>   forEach(rData, function(rRow) {
> > >>> dataArr.push(values(rRow));
> > >>>   });
> > >> Yes there is: var dataArr = map(values, rData);
>
> > It's a bad idea to use either of these solutions, since JavaScript
> > object properties are not ordered.  While it may happen to be that the
> > keys produced by a ``for (k in o)`` (as in ``keys(o)`` and ``items(o)``)
> > loop are produced in a stable order in current browsers, it should not
> > be counted on.  If some browser changes their implementation, the
> > columns in your table may change order or even contain data that belongs
> > in other columns.  This is also asking for cross-browser differences, as
> > different JavaScript implementations are likely to differ on this point.
>
> > You should incorporate an array of the keys into either your code or the
> > data structure so that you can access them in the correct order.
>
> Tom is absolutely right.
>
> To ease cases like this, maybe we should have a utility function in
> base like getItems:
>
> function getItems(keys, obj) {
> return map(function (key) { return obj[key]; }, keys);
>
> }
>
> especially intended for stuff like partial(getItems, ['firstname', 
> 'lastname']).
>
> ...or maybe just extend itemgetter to accept an array as a parameter, so that
> itemgetter(['x','y'])({'x':10, 'y': 20}) == [10, 20]
>
> Arnar


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~--~~~~--~~--~--~---



[mochikit] Re: Bugfixes in Selector, DOM

2007-02-07 Thread Thomas Hervé



On 7 fév, 11:44, "Aaron Faanes" <[EMAIL PROTECTED]> wrote:
> The following is a couple bugfixes in Selector (just some unqualified
> names that have been lurking)

OK corrected.

> There's also a few times in Selector where MochiKit.Format.trim could
> be used, but isn't. It's not too big a deal, but it seems like if it's
> already in MochiKit, it should be used in MochiKit.

Actually Format.trim doesn't exist, so it'd be hard to use :).

> Also a minor addition to DOM renames since IE blows and doesn't
> recognize cellspacing.

That seemed good, I added it.

Thanks!

--
Thomas



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~--~~~~--~~--~--~---



[mochikit] Bugfixes in Selector, DOM

2007-02-07 Thread Aaron Faanes

The following is a couple bugfixes in Selector (just some unqualified
names that have been lurking)

There's also a few times in Selector where MochiKit.Format.trim could
be used, but isn't. It's not too big a deal, but it seems like if it's
already in MochiKit, it should be used in MochiKit.

Also a minor addition to DOM renames since IE blows and doesn't
recognize cellspacing.

Hope this is useful to you guys

 - Aaron Faanes

===
--- DOM.js  (revision 1262)
+++ DOM.js  (working copy)
@@ -1139,6 +1139,8 @@
 "for": "htmlFor",
 "readonly": "readOnly",
 "colspan": "colSpan",
+   "cellspacing":"cellSpacing",
+   "cellpadding":"cellPadding",
 "bgcolor": "bgColor"
 };
 } else {
Index: Selector.js
===
--- Selector.js (revision 1262)
+++ Selector.js (working copy)
@@ -292,7 +292,7 @@

 /** @id MochiKit.Selector.Selector.prototype.isUIElement */
 isUIElement: function (element) {
-return findValue(['input', 'button', 'select', 'option',
'textarea', 'object'],
+return MochiKit.Iter.findValue(['input', 'button', 'select',
'option', 'textarea', 'object'],
 element.tagName.toLowerCase()) > -1;
 },

@@ -341,7 +341,7 @@
 }

 if (axis == "") {
-scope = (scope ||
currentDocument()).getElementsByTagName(this.params.tagName || '*');
+scope = (scope ||
MochiKit.DOM.currentDocument()).getElementsByTagName(this.params.tagName
|| '*');
 } else if (axis == ">") {
 if (!scope) {
 throw "> combinator not allowed without preceeding
expression";


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~--~~~~--~~--~--~---



[mochikit] Re: More function suggestions

2007-02-07 Thread Arnar Birgisson

Hi there,

Those are all good additions imo.

On 2/7/07, Chris Nokleberg <[EMAIL PROTECTED]> wrote:
> // reverse of itemgetter (perhaps there is a better name)
> getteritem: function (obj) {
> return function (arg) {
> return obj[arg];
> }
> }

Maybe "propertygetter"? When I started using MochiKit I was actually
often confused if itemgetter did this or what it really does.

Arnar

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~--~~~~--~~--~--~---



[mochikit] More function suggestions

2007-02-07 Thread Chris Nokleberg

Here are some more suggestions for additions to Base/Iter. These are
all functions that I currently use multiple times in my own code and
seem generic enough.

Thanks,
Chris

// reverse of Base.items, I believe this was semi-approved by Bob
earlier
fromItems : function(items) {
var obj = {};
MochiKit.Iter.forEach(items, function(item) {
obj[item[0]] = item[1];
});
return obj;
}

// round out logical operators
logxor: function (a, b) { return (a || b) && !(a && b); }

// reverse of itemgetter (perhaps there is a better name)
getteritem: function (obj) {
return function (arg) {
return obj[arg];
}
}

// a simple way to do a deep clone
cloneJSON : function (value) {
return MochiKit.Base.evalJSON(MochiKit.Base.serializeJSON(value));
}

// like next, but return null if there are no more left instead of
throwing exception
nextOrNull : function(iter) {
try {
return iter.next();
} catch (e) {
if (e != MochiKit.Iter.StopIteration)
throw e;
return null;
}
}


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~--~~~~--~~--~--~---