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

Test removal of selectors #27

Closed
wants to merge 3 commits into from

Conversation

@dy
Copy link

commented Oct 7, 2019

This fixes #26.
this.selectors seems to be a shallow property, not engaged in internal logic, so we can safely remove items from it.
@josh

@@ -310,6 +310,7 @@ SelectorSet.prototype.remove = function(selector, data) {
if (obj.selector === selector && (removeAll || obj.data === data)) {
objs.splice(k, 1);
removedIds[obj.id] = true;
removedSelectors[obj.selector] = true;

This comment has been minimized.

Copy link
@josh

josh Oct 7, 2019

Owner

I think removing by selector string might not work when two selectors exist with different data properties.

set.add('.foo', 1)
set.add('.foo', 2)
set.remove('.foo', 2)
set.selectors // should still include '.foo'
set.remove('.foo', 1)
set.selectors // should now be empty

This comment has been minimized.

Copy link
@josh

josh Oct 9, 2019

Owner

Add a test case that passes on master but fails on this branch 2445317

this.size -= Object.keys(removedIds).length;
this.selectors = this.selectors.filter(function (selector) { return removedSelectors[selector] })

This comment has been minimized.

Copy link
@josh

josh Oct 7, 2019

Owner

I'd probably still like to avoid ES5 runtime features like filter in this project. I know it's super old, but I don't think any of this code makes use of them.

Copy link
Owner

left a comment

Heh, maybe this was just originally an oversight since the cleanup is a little tricky.

@josh

This comment has been minimized.

Copy link
Owner

commented Oct 9, 2019

What do you think about #29?

@josh josh closed this in #29 Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.