Oops, John, sorry, I think I misunderstood your message... did you mean
implementing a "has" method by using native "contains" and
"compareDocumentPosition"? If yes, it seems much more reasonable, since it
can be applied to other nodes than document.documentElement or
someElement.ownerDocument...

Diogo



On Wed, Dec 17, 2008 at 5:42 PM, Diogo Baeder <[email protected]> wrote:

> Hi, John,
>
> Maybe I got it wrong, but I think the main idea was to create a method that
> could be used several times, if needed, to test the elements existance, say,
> on a variable pointing to a jQuery object... for example, if you need to
> test an array element several times during a processing, and, if at some
> point it relates to a non-existant element, it's removed from the list, thus
> preventing a memory leak. I thought about this situation because I already
> passed by one of this kind, but maybe I'm thinking of something that may not
> be that necessary to everyone, though...
>
> Just synthetizing the discussion on the group thread, this is the
> difference between the first and the last implementations of the method -
> during a 1000 iterations test -:
>
> - First implementation: 451ms on my machine (using traversal);
> - Last: 43ms on my machine (using native code to test document elements
> supporting also iframes and XML).
>
> Thank you :-)
>
> Diogo
>
> P.S.: Someone has told me jQuery might have some native implementation in
> some future Firefox version... maybe just a silly rumour? Nevertheless, it
> would be interesting how one would put hands on the FF C source code and
> insert a fast as hell jQuery in it... :-)
>
>
>
> John Resig escreveu:
>
>  Diogo -
>>
>> I would rather shoot for something that's a little more idiomatic to
>> jQuery. For example jQuery already has a way to figure out if an
>> element contains a selector: "div:has(a)".
>>
>> Thus, I think a better result would be:
>> $("div").has("a") // true
>> $(document).has("div") // true
>> $(document).has(document.getElementsByTagName("div")[0]); // true
>>
>> --John
>>
>>
>>
>> On Tue, Dec 16, 2008 at 4:37 PM, Diogo Baeder <[email protected]>
>> wrote:
>>
>>
>>> Great ones, John!
>>>
>>> What about "isOrphan()" or "inDOM()" methods, to prevent uneeded JS
>>> processing for non-existant elements, as discussed before?:
>>>
>>> http://groups.google.com/group/jquery-dev/browse_thread/thread/ac5ca8eaa64fe9f1/af83ebdd79de479a?q=indom&lnk=ol&;
>>>
>>> Maybe a long discussion, but everybody contributed for the community to
>>> have a nice implementation, right?!
>>>
>>> Congratulations for the great work!
>>>
>>> Diogo
>>>
>>>
>>>
>>> John Resig escreveu:
>>>
>>>
>>>> Hi Everyone -
>>>>
>>>> I have the first round of jQuery 1.3 patches ready:
>>>> http://dev.jquery.com/~john/jquery1.3/<http://dev.jquery.com/%7Ejohn/jquery1.3/>
>>>>
>>>> This is in addition to the Sizzle selector engine patch which I posted
>>>> a little bit ago (and which I'll be making an updated version of very
>>>> soon).
>>>>
>>>> The patches are as follows:
>>>>
>>>> append.patch: Use DocumentFragment in .domManip. This is a large
>>>> overhaul of .domManip (and moves some of the logic into jQuery.clean).
>>>> The result is that manipulation code (append/prepend/etc.) is about
>>>> 15x faster. During this overhaul I made a change to how scripts are
>>>> executed. Roughly it means that scripts that are brought in as a
>>>> string and inserted are executed - but scripts that exist as DOM nodes
>>>> are not. This will solve the common problem wherein a script that
>>>> already exists in the page will be dual-executed. Let me know if this
>>>> affects your code - I suspect we'll learn more during the beta, as
>>>> well.
>>>>
>>>> append-2.patch: Just in case, this is the same patch as above, but
>>>> with the old-style of functionality intact.
>>>>
>>>> closest.patch: This adds a new method: .closest(selector). You can
>>>> think of it as .firstSelfOrAncestor. This has been a commonly
>>>> requested function and it will make implementing delegation code
>>>> trivial.
>>>>
>>>> domready.patch: An overhaul of the ready code, removing the the "wait
>>>> for stylesheets to load" logic. I did a bunch of testing on this and
>>>> it really appears as if it's impossible to get proper stylesheet
>>>> loading detection implemented (I wanted to have a "cssready" event for
>>>> 1.3, but it's not looking likely). Instead we need to back off and
>>>> simply provide normal DOM ready functionality in .ready(). This means
>>>> that we need to educate users to include their stylesheets before
>>>> their scripts in order for them to be accessible in time for DOM
>>>> ready.
>>>>
>>>> multi-namespace.patch: This adds multiple-namespace support to events.
>>>> Previously you could only do it with one namespace e.g.
>>>> .bind("click.foo") or .trigger("click.foo"). The patch allows you to
>>>> use any number of namespaces e.g.
>>>> .bind("click.foo.bar").trigger("click.bar").unbind(".bar.foo").
>>>>
>>>> selector.patch: Adds a new internal property that keeps track of the
>>>> selector chain.
>>>> $("div").find("span").filter(":hidden").parent().selector == "div
>>>> span.filter(:hidden).parent()". This is meant to be used by plugins
>>>> (like liveQuery), primarily. The implementation of selectors like
>>>> .parent() will be coming in a follow-up patch along with Sizzle.
>>>>
>>>> strict.patch: Makes it so that we pass strict mode in Firefox 3. Only
>>>> a few minor tweaks necessary.
>>>>
>>>> I have the following patches coming:
>>>>  - Landing Sizzle
>>>>  - Landing .parent()/.filter()/etc. selector implementation.
>>>>  - Native event delegation
>>>>  - Removing the remaining uses of jQuery.browser
>>>>
>>>> --John
>>>>
>>>>
>>>>
>>>
>> >>
>>
>>
>>
>


-- 
Diogo Baeder
http://www.diogobaeder.com.br

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to