View Single Post
  #42  
Old   
Garrett Smith
 
Posts: n/a

Default Re: viewing ajax source - 08-17-2009 , 03:03 AM






kangax wrote:
Quote:
Garrett Smith wrote:
kangax wrote:
Garrett Smith wrote:
[...]
[about vxJS, comments about browsers, etc]

Quote:
A new DOM_CONSTANT that I think you might like for CFT:

var od = "ownerDocument",
doc = document,
docEl = doc.documentElement,
OWNER_DOCUMENT = docEl && od in docEl ? od : "document";

I've been a bit turned off by this string munging lately. I know it
minifies much better (YUI3 seem to be using it a lot) but it makes for a
somewhat less readable code; besides following the logic flow, you now
have to keep in mind what some of these short (and so undescriptive)
variable names translate to.

In the case above, though, I assinged to "dom.OWNER_DOCUMENT". No munging.

el[dom.OWNER_DOCUMENT]

A debugger would have the ability to resolve those identifiers, though,
so one could add a "watch" and type that in.

Quote:
This seems like a better job for some kind of a pre-processor, where you
specify which strings can be replaced with variables (and so replaced
with shorter names during minification).

It is useful for a load time constant. A dynamic property is going to be
faster than a function call that accesses that property.

For example:-
el[dom.OWNER_DOCUMENT]

- will be faster than:-

dom.getOwnerDocument(el)

dom.getOwnerDocument = function(el) {
return el.ownerDocument;
};

- because the former is a property lookup to get dom.OWNER_DOCUMENT, the
latter is a lookup to dom.getOwnerDocument, and the latter is a [[Call]]
expression.

Quote:
IE 5, Safari 2, and even Mac IE, have a "document" property on
elements. That property is the same thing as ownerDocument.

Ah, but I see that Safari 2 has `ownerDocument` too, so what's the
advantage of `document` over `ownerDocument`? Does IE5 and Mac IE lack it?

Safari 2 and Mac IE have both. IE 5.5 has node.document, but not
node.ownerDocument. IE 6 up has both.

Quote:
The problem is where there is a browser that has neither
el.ownerDocument nor el.document. Check your BlackBerry and let us
know (please).

`ownerDocument` exists and references a document on Blackberry 9530

Hmm. Should I remove dom[OWNER_DOCUMENT] and let it fail in IE 5.5?

It's not that much extra code to support, but then again, it is only IE
5.5, which is pretty old.

[...]

Quote:
Safari 2 is kind of, well, it's on its way out.

I actually still see few users of Safari 2.0.4 (last in 2.x series) on
my employer website (http://www.artstor.org) which gets ~3K visits a
day. I also see a lot (!) of Safari 1.3 users (even more than 2.x),
apparently all those people stuck with older Mac OS and so can't upgrade
to 2.x+. No wonder why BBC supports Safari 1.3 with their in-house Glow
library <http://www.bbc.co.uk/glow/

Yeah. Lets look at getting some more stuff working in older versions of
Safari. hasOwnProperty, e.g.

Quote:

Then there are other minor things such as `Array#map` implementation
not matching JS1.6 one (now codified in ES5 too); color abstraction
not supporting `rgba`-based values (or `hsl` ones); native objects'

I think it depends on the context where that is needed. In a color
transition, rgba is often not needed. For that, it might not be wort
it; maybe easier to just have rgb and opacity separate. Then again, if
it is an easy add, and easy to test, then it might be worth it.

Perhaps not. I just notice myself using `rgba` more and more often as it
looks better, falling back on `rgb` in non-supporting clients.
I took "color abstraction" to mean some sort of Color ADT or "class". My
comment was based on that understanding. Now it seems like you are
talking about support of css rgba. There seems to be a misunderstanding.

Quote:

extensions (e.g. Array#create, String#setProp), so often criticized
in Prototype.js; array checks done in cross-frame incompatible manner
(<smth>.constructor == Array); usage of `window` instead of
`global.window`; and others.


I usually don't need to see if something is an array. I would probably
one-off a feature test on-the-spot.

What do you mean?

Like, if I had a case where - someIdent - could be either, say, and -
arguments - object or an Array, and I wanted to call - concat - if it is
an array, then I could check to see if that has a concat, and, provided
I don't have a formal parameter named - concat -, I'll use:-

if(typeof someIdent.concat == "function") {
// can I have a dollar?
}

[...]

Quote:
Well, as we have found out on ES5 mailing list a couple of days ago,
Flanagan actually wrote about [[Class]] checking on 175th page of its
book back in 2006 It wasn't really used for type-checking across
frames (which is what I focused on in my post) and would actually fail
due to following `constructor` checks, but still...

https://mail.mozilla.org/pipermail/e...st/003080.html

Shall we be diplomatic and call it the Flanagan-kangax-miller-device?

:-D

[...]

Quote:
Yep, I liked that too. I think APE might benefit from cutting some of
its god-like methods into smaller chunks

Adding WebkitTopRightBorderRadius didn't help much, did it ;-D

You want the honors? Yank out border radius support. There's one unit
test and one animation demo uses animated border radius. That demo also
uses the deprecated APE.getById, which can be replaced by
APE.createFactory. That'll get style-f.js down closer to 200 LOC.

No rush. There never deadlines with APE :-D. Craftsmanship above all.

In other areas, getOffsetCoords fails a few tests in Safari 2.

More examples (demos) for animation and drag drop would be good.

I am simplifying Draggable. Using "APE.createFactory simplified the
interface and helped get the file size down -- 11k minified and shrinking.

Oh, I also use a MOUSE_MOVE_THRESHOLD to reduce CPU strain in mousemove.

var now = +new Date;
if(now - lastMouseMoveTime < MOUSE_MOVE_THRESHOLD) return;
lastMouseMoveTime = now;

When mousemove is entered, I check the current time and compare that to
the last recorded time (initially -1). If that is less than the
MOUSE_MOVE_THRESHOLD, the function exits. This has the effect of
creating new Date each mousemove, which is significantly less CPU than
dragging an element around.

I removed the "constraint" feature, removed the out-of-place focus
management. Next up for consideration is removing the "animateBack", for
when the user hits Esc (as on Mac) though it might be worth
consideration to do that, but only when Animation is available. I'd like
to find someone local few hours a week, to pair on stuff.

Garrett
--
comp.lang.javascript FAQ: http://jibbering.com/faq/

Reply With Quote