GithubHelp home page GithubHelp logo

Context support about engine HOT 8 CLOSED

elisnow avatar elisnow commented on August 18, 2024
Context support

from engine.

Comments (8)

EliSnow avatar EliSnow commented on August 18, 2024

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.

from engine.

pyrsmk avatar pyrsmk commented on August 18, 2024

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';
    }
}

from engine.

EliSnow avatar EliSnow commented on August 18, 2024

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.

from engine.

pyrsmk avatar pyrsmk commented on August 18, 2024

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).

from engine.

EliSnow avatar EliSnow commented on August 18, 2024

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

from engine.

pyrsmk avatar pyrsmk commented on August 18, 2024

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?

from engine.

EliSnow avatar EliSnow commented on August 18, 2024

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 <
[email protected]>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)

from engine.

pyrsmk avatar pyrsmk commented on August 18, 2024

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.

from engine.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.