Skip to content
This repository has been archived by the owner on Apr 5, 2018. It is now read-only.

Context support #1

Closed
pyrsmk opened this issue May 12, 2011 · 8 comments
Closed

Context support #1

pyrsmk opened this issue May 12, 2011 · 8 comments

Comments

@pyrsmk
Copy link

pyrsmk commented May 12, 2011

Hi,

Your engine looks great, but since it doesn't support DOM contexts it can't handle many behaviors :s

@EliSnow
Copy link
Owner

EliSnow commented May 12, 2011

pyrsmk, I assume by "DOM contexts" you mean XML support. Is that correct? Please clarify.

XML support is something I plan on adding but it has not happened yet.

In other news I do have a new version I am close to releasing where the code has almost completely been rewritten. It is much more efficient, much faster, and even quite a bit smaller. The caching engine is no longer an internal part of Engine and instead will be an optional feature.

Anyways, thanks for your interest and please let me know of any other problems.

@pyrsmk
Copy link
Author

pyrsmk commented May 12, 2011

In fact... No :D

I mean that Sizzle, qwery, and others, have a context support that permit us to specify a parent element where to search the selector.

Per example, I want to put some event handling on list elements which contain other elements. When I hover a list item an element (like an <a>) will get some colors. This is a huge naive example but:

var elements=engine('#menu li');
for(var i in elements){
    elements[i].onmouseenter=function(){
        engine('a',elements[i]).style.color='white';
    }
    elements[i].onmouseleave=function(){
        engine('a',elements[i]).style.color='black';
    }
}

@EliSnow
Copy link
Owner

EliSnow commented May 12, 2011

Ok, that makes sense. Again for clarification, should the line

engine('a',elements[i]).style.color='white';

instead be written:

engine('a',elements[i])[0].style.color='white';

because engine would return an array?

You will be happy to know, in any regard, that that very feature is in the next version which I hope to have released within the next couple days. I hope that you will let me know if it works as it should.

@pyrsmk
Copy link
Author

pyrsmk commented May 12, 2011

Oh, yes, you're right! I written that with my feet :p

Great! Be sure I will grap it when it will be released. I love little projects and, right now, I'm dealing with Sizzle.He does well is job but it's quite heavy. I was very interested by the qwery engine, but I need CSS3 and I just can't do without it (less semantics in HTML, the better, the future).

@EliSnow
Copy link
Owner

EliSnow commented May 15, 2011

The next version is up, please give it a try and let me know if it is working properly

@pyrsmk
Copy link
Author

pyrsmk commented May 15, 2011

Nice, all work on my website with a simple "replace Sizzle by engine". Great work :)

One question: why have two versions? One with cache, the other without?

@EliSnow
Copy link
Owner

EliSnow commented May 15, 2011

The biggest reason I put it as two versions is for those who really want to
cut down on the size. While caching greatly increases query speeds for
repeat selectors, I do not know how practical it is in a production
environment. Are repeat selectors used that often that it warrants the extra
0.5KB file size? I don't know, that's why, for now, the user can choose.
Later on I hope to have a better method to allow people to choose which
selectors/features they want to include in their script.

As a heads up, I discovered this morning that the caching function is not
removing duplicates from the returned array. For example a selector of
"p:nth-child(odd), p:first-child" would likely return duplicates. So if you
are using the caching version I should have that fixed very shortly.

On Sun, May 15, 2011 at 1:03 PM, pyrsmk <
reply@reply.github.com>wrote:

Nice, all work on my website with a simple "replace Sizzle by engine".
Great work :)

One question: why have two versions? One with cache, the other without?

Reply to this email directly or view it on GitHub:
#1 (comment)

@pyrsmk
Copy link
Author

pyrsmk commented May 15, 2011

I see... To my mind, 500 octets can be "problem" with high traffic website (perhaps, don't know really) and caching is much more important because there are several clients with low performance capabilities such as mobiles, netbooks, notebooks, old desktops, ...

And... How can "p:nth-child(odd), p:first-child" return duplicates with caching and not with the normal selection? Isn't there a code factoring issue with this? Or maybe I misunderstand something.

@EliSnow EliSnow closed this as completed May 16, 2011
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants