Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOM] Improve some methods #1821

Open
brunocoelho opened this issue May 15, 2014 · 6 comments
Open

[DOM] Improve some methods #1821

brunocoelho opened this issue May 15, 2014 · 6 comments

Comments

@brunocoelho
Copy link
Contributor

I was wondering if it is a good idea to make some methods accept regex to do queries instead of only strings.

I have some nodes using bootstrap grid column class, which could be different according to some situations, for example: col-xs-3, col-sm-2, col-md-10 or col-lg-1. As you can see it changes only the part on the middle of it.

At some time I want to do a query to know if some node has a class of that type, something like this:

node.hasClass(/col-(?:xs|sm|md|lg)-(\d+)/);

Is it a good idea to support regex in this case?

I thought in something like this:

hasClass: function(node, className) {
    var re;

    if (typeof className === 'string') {
        re = Y.DOM._getRegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
    }
    else {
        re = className;
    }

    return re.test(node.className);
}
@okuryu
Copy link
Member

okuryu commented May 16, 2014

I would like to bring Selectors Level 4 Polyfills for these use cases in the future. I believe this will be a standard spec. It will be able to landed many new features such as :matches(), :has() selectors.

@brunocoelho
Copy link
Contributor Author

Yeah, it would be nice. So, today there's nothing we can do, right?

@clarle
Copy link
Collaborator

clarle commented May 18, 2014

@okuryu 👍 on that initiative. I would definitely like to see that happen.

@okuryu
Copy link
Member

okuryu commented May 18, 2014

I'll try to work for that.

@brunocoelho
Copy link
Contributor Author

I would love to help with it, but things could be easier if there were a kind of roadmap.
Let me know when you start to plan it.

@triptych
Copy link
Contributor

this would be an excellent thing to start as a thread in https://groups.google.com/forum/#!forum/yui-contrib to get interested parties discussing it, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants