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

Support scoped selectors #20

Open
lazd opened this issue Nov 11, 2014 · 0 comments
Open

Support scoped selectors #20

lazd opened this issue Nov 11, 2014 · 0 comments

Comments

@lazd
Copy link

lazd commented Nov 11, 2014

With markup such as:

<nav id="menu" class="menu">
  <a href="#" class="menu-title">Furniture</a>
  <nav class="menu">
    <a href="#" class="menu-title">Chairs</a>
  </nav>
  <nav class="menu">
    <a href="#" class="menu-title">Couches</a>
  </nav>
</nav>

The following test should pass:

var spy = sinon.spy();

var menu = document.querySelector('#menu');
Gator(menu).on('click', '> .menu-title', function() {
   expect(event.target.parentNode).to.equal(menu);
});


var titles = menu.querySelectorAll('.menu-title');

for (var i = 0; i < titles.length; i++) {
  dispatch('customEvent', titles[i]);
}

expect(spy.callCount).to.equal(1, 'spy call count after dispatching events on every .menu-title');

This is supported in jQuery and a pull request to add this functionality has been sent against ftdomdelegate Financial-Times/ftdomdelegate#50

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

1 participant