Re: [JSMentors] Re: Post/repo on small something to help with checking for object "conformance"

2011-03-22 Thread Stefan Weiss
On 23.03.2011 02:35, Scott Sauyet wrote: npup wrote: That said, I am one of those who prefer throwing immediately instead of if-else-ing too much and thereby having the real work being done in some unnecessarily indented part of the code :) I tend to be the same way, at least in JS. But I

[JSMentors] Re: Post/repo on small something to help with checking for object "conformance"

2011-03-22 Thread Scott Sauyet
npup wrote: > Scott Sauyet wrote: > >> I was suggesting something different, namely that the inverted sense >> might be nicer to use in coding.  I still don't have a better name >> than "mismatches", which is fairly ugly. > >> What I didn't like about npup's original is that this was handled with >

[JSMentors] Re: Post/repo on small something to help with checking for object "conformance"

2011-03-22 Thread npup
On Mar 22, 5:21 pm, Scott Sauyet wrote: > I think "reflects" (not "reflect" -- don't you love English where > adding an "s" makes nouns plural and verbs singular?!) has a similar > sense as "ActsAs". > > I was suggesting something different, namely that the inverted sense > might be nicer to use

[JSMentors] Re: Post/repo on small something to help with checking for object "conformance"

2011-03-22 Thread Scott Sauyet
Diego Perini wrote: > Scott Sauyet wrote: >> Diego Perini wrote: >>> Just a minimal name suggestion, could "reflect" work instead of "ActsAs" ? > >>> Hope I have correctly interpreted the sense/intent the name must give :) > >> I think "reflects" (not "reflect" -- don't you love English where >> ad

Re: [JSMentors] Re: Post/repo on small something to help with checking for object "conformance"

2011-03-22 Thread Diego Perini
On Tue, Mar 22, 2011 at 5:21 PM, Scott Sauyet wrote: > Diego Perini wrote: >>Scott Sauyet wrote: >>> npup wrote: > I wrote a little utility to help out with checking status of objects. More specifically, checking their conformance with a "signature" that you provide along with the c

[JSMentors] Re: Post/repo on small something to help with checking for object "conformance"

2011-03-22 Thread Scott Sauyet
Diego Perini wrote: >Scott Sauyet wrote: >> npup wrote: >>> I wrote a little utility to help out with checking status of objects. >>> More specifically, checking their conformance with a "signature" that >>> you provide along with the check. >> [ ... ] >> But I'm not thrilled with the API.  The fi

Re: [JSMentors] DOM Node Tree manipulation patterns?

2011-03-22 Thread Diego Perini
On Tue, Mar 22, 2011 at 11:54 AM, Tim Down wrote: > On 20 March 2011 00:12, Will Rock wrote: >> Hey all, >> >> I'm playing around with contentEditable and I'm current working with >> styling (bold, italic, etc...) of the current selection >> (window.getSelection()). Now, I know I can do this via

Re: [JSMentors] Re: Post/repo on small something to help with checking for object "conformance"

2011-03-22 Thread Diego Perini
On Tue, Mar 22, 2011 at 1:15 PM, Scott Sauyet wrote: > npup wrote: >> I wrote a little utility to help out with checking status of objects. >> More specifically, checking their conformance with a "signature" that >> you provide along with the check. > > As I responded in the blog comments, I'm mix

Re: [JSMentors] Pushing to Arrays

2011-03-22 Thread Tony Wang
I think it's very important to find a better optimizing way for Array in different situation, your application Performance could be consist of Array over 30% . (Array used anywhere!) (For example , if you are using jQuery , it means you are facing a lot of Dom Arrays) And we usually use Array to

[JSMentors] Re: Post/repo on small something to help with checking for object "conformance"

2011-03-22 Thread Scott Sauyet
Poetro wrote: > Have you looked at http://json-schema.org/? There are various > implementations of it at http://json-schema.org/implementations.html That looks like much more than what npup is doing. In fact, for my uses it seems over the top. I understand that it might make for a useful contrac

[JSMentors] Re: Post/repo on small something to help with checking for object "conformance"

2011-03-22 Thread Scott Sauyet
npup wrote: > Scott Sauyet wrote: >> npup wrote: >> [ ... ] >> This perhaps sounded overly negative.  My main reaction is that this >> is a good idea, and a reasonable stab at a first implementation, but >> there is significant room for improvement.  Thanks for sharing it. > > Oh thanks for your in

[JSMentors] Re: Post/repo on small something to help with checking for object "conformance"

2011-03-22 Thread npup
On Mar 22, 1:30 pm, Poetro wrote: > Have you looked athttp://json-schema.org/? There are various > implementations of it athttp://json-schema.org/implementations.html. > They do object validation based on the schema and also does a bunch of > other funky stuff, that are cool. Check for > exampl

Re: [JSMentors] Re: Extending built-in objects with properties

2011-03-22 Thread Christophe Porteneuve
Hey Jarek, Be very wary of this, as your namespace expando (e.g. the "ext" property in there has a number of potential pitfalls: * Any other script in place can overwrite it * Your methods are bound to the expando, not the prototype. So their binding (what "this" will mean inside them) is b

[JSMentors] Re: Post/repo on small something to help with checking for object "conformance"

2011-03-22 Thread npup
On Mar 22, 1:15 pm, Scott Sauyet wrote: > npup wrote: > > I wrote a little utility to help out with checking status of objects. > > More specifically, checking their conformance with a "signature" that > > you provide along with the check. > > As I responded in the blog comments, I'm mixed about

Re: [JSMentors] Re: Extending built-in objects with properties

2011-03-22 Thread Christophe Porteneuve
Le 21/03/2011 02:59, RobG a écrit : Don't do that. Do not mess with host objects, you do not know how they will deal with added properties. Oh, and you don't have to take my word for it: Kangax, "What’s wrong with extending the DOM", 5 April 2010

Re: [JSMentors] Re: Post/repo on small something to help with checking for object "conformance"

2011-03-22 Thread Poetro
Have you looked at http://json-schema.org/ ? There are various implementations of it at http://json-schema.org/implementations.html. They do object validation based on the schema and also does a bunch of other funky stuff, that are cool. Check for example https://github.com/akidee/schema.js and htt

[JSMentors] Re: Extending built-in objects with properties

2011-03-22 Thread Scott Sauyet
On Mar 21, 9:48 am, RobG wrote: > On Mar 21, 10:30 pm, Jarek Foksa wrote: > To do this stuff robustly, you often need to use getters and setters, > so: > > Element.prototype.uXgetDisabled = function() {...} > Element.prototype.uXsetDisabled = function(arg) {...} I'm curious as to why you think

Re: [JSMentors] Re: Array and for/in syntax

2011-03-22 Thread Tim Down
On 16 March 2011 22:45, RobG wrote: > Chrome is compliant with ES 3 and ES 5 in that regard. There is no > reason to believe any browser will return object properties in the > order they were added, both specifications quite clearly state that. > > >> Seehttp://code.google.com/p/chromium/issues/de

Re: [JSMentors] DOM Node Tree manipulation patterns?

2011-03-22 Thread Tim Down
On 22 March 2011 10:54, Tim Down wrote: > Two things: first, I've implemented this in Rangy, my cross-browser > range and selection library (http://code.google.com/p/rangy/). There's > a module that applies/removes a CSS class to a range by surrounding > and removing spans around text nodes within

Re: [JSMentors] DOM Node Tree manipulation patterns?

2011-03-22 Thread Tim Down
On 20 March 2011 00:12, Will Rock wrote: > Hey all, > > I'm playing around with contentEditable and I'm current working with > styling (bold, italic, etc...) of the current selection > (window.getSelection()). Now, I know I can do this via > document.execCommand (in certain browsers), but I'd like

[JSMentors] Re: Advantages & Disadvantages of Dependency-Injecting Non-Instantiable Objects

2011-03-22 Thread Rob Brackett
Hi George, in my experience, the dependency-injected model you describe is almost always better, even in the case of static/non- instantiable/singleton objects. The first benefit is obviously that you can mock the dependency. This is often still valuable for non-instantiable objects, although, as