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

Selector functions #1064

Closed

Conversation

onedayitwillmake
Copy link

Please note: The code in this pull request was written by myself, and is does not represent my employer.

updated 4/08/15
updated 4/09/15

I rebased the PR #1019 and removed Xcode references.

I have 8 of the 8 built, I started from the bottom for some reason.
Bold means they are in and passing the test.

I'm still actively working on this - however being my second PR and new to the library I wanted to make sure anyone could catch any silly things I was doing.

  • selector-nest($selectors...)
  • selector-append($selectors...)
  • selector-extend($selector, $extendee, $extender)
  • selector-replace($selector, $original, $replacement)
  • selector-parse($selector)
  • simple-selectors($selector)
  • is-superselector($super, $sub)
  • selector-unify($selector1, $selector2)

Some notes:

  • Added stub functions
  • Passing 'Contextualize' to `Native_Function signature in BUILT_IN(name) Expression*
  • Added ARGSELL to compliment ARG, ARGR, ARGM since all the selector functions rely on that so heavily
  • Had to do some hairy things to get Selector_List::selector_unify and Selector_List::selector_unify to work
  • Added public static methods version of Extend's subweave, for now I named it StaticSubweave just to make sure I don't step on any toes, will remove floating one if that seems fine to everyone
  • Added a naiveTrim function to Node that removes any duplicate selectors (this is for Complex_Selector::unify_with was returning correct results but the final shared selector would sometimes appear twice, and blindly adding everything else in the collection (I could not get node's existing trim implementation to work - I Also could not find any references to it be used.
  • Added a public static version of Extend's extendSelectorList
  • Added param isReplace to Extend::extendSelectorList - which does not add the Selector if an extension takes place.
  • Added Vectorized<T>::first to compliment Vectorized<T>::back in order to make selector_append code more clear,

@mgreter
Copy link
Contributor

mgreter commented Apr 7, 2015

Hey @onedayitwillmake great work so far 👍

I guess it is already passing quite a few todo tests? I also expect a few other extend bugs to be solved by this work, since it should fix/improve the is_superselector function. Maybe you have such a list? Otherwise I could add it since I have pretty much everything in place to generate it automatically with perl-libsass (IMO it should also be possible via sassc, but I never use it)!

Will definitely give it a thorough review after we released 3.2 🎆

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.58%) to 79.06% when pulling a7e93f8 on onedayitwillmake:selector_functions into 0135278 on sass:master.

@mgreter
Copy link
Contributor

mgreter commented Apr 7, 2015

Gave it a whirl and these tests pass now on my side 😃

  • selector-functions/extend
  • selector-functions/parse
  • selector-functions/replace
  • selector-functions/extend/nested
  • selector-functions/is_superselector/any_is_not_superselector_of_different_prefix
  • selector-functions/is_superselector/complex_superselector
  • selector-functions/is_superselector/compound_superselector
  • selector-functions/is_superselector/current_is_superselector_with_identical_innards
  • selector-functions/is_superselector/current_is_superselector_with_subselector_innards
  • selector-functions/is_superselector/descendant_is_superselector_of_child
  • selector-functions/is_superselector/following_sibling_is_superselector_of_next_sibling
  • selector-functions/is_superselector/leading_combinator
  • selector-functions/is_superselector/matches_is_not_superselector_of_any
  • selector-functions/is_superselector/matching_combinator
  • selector-functions/is_superselector/not_is_not_superselector_of_non_unique_selectors
  • selector-functions/is_superselector/reflexivity
  • selector-functions/is_superselector/selector_list_subset
  • selector-functions/is_superselector/trailing_combinator

@onedayitwillmake
Copy link
Author

@mgreter Would be great if you could generate it!

@mgreter @xzyfer Re: $selector-append
I have the function working with functionally correct output, however in ruby-sass the output is ordered alphabetically.

To give an example:

input: selector-append(".a", ".b, .c", ".de, .df, foo");
// ruby-sass
.a.b.de, .a.b.df, .a.bfoo, .a.c.de, .a.c.df, .a.cfoo;
// libsass 
.a.b.de, .a.c.de, .a.b.df, .a.c.df, .a.bfoo, .a.cfoo;

I could sort all the Complex_Selectors in the Selector_List, after the operation - but I'm not sure if that would be the right thing to do. Any advice?

Whoops, swapping the iteration order of the loop fixes the issue.
See: 7ccaece

@xzyfer xzyfer mentioned this pull request Apr 8, 2015
@onedayitwillmake
Copy link
Author

@mgreter @xzyfer Alright! Implemented selector-nest to make the full set

@coveralls
Copy link

Coverage Status

Coverage decreased (-4.4%) to 76.24% when pulling 189fa0d on onedayitwillmake:selector_functions into 0135278 on sass:master.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 0c606ea on onedayitwillmake:selector_functions into * on sass:master*.

@onedayitwillmake
Copy link
Author

@mgreter @xzyfer Do you guys have any advice on fixing the build errors in some of the travis-ci builds? It looks like it's failing on the issue_1075, in only some of the builds

@xzyfer
Copy link
Contributor

xzyfer commented Apr 10, 2015

@onedayitwillmake if you apply this change you should be good

screen shot 2015-04-10 at 1 43 08 pm

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 1e71a09 on onedayitwillmake:selector_functions into * on sass:master*.

@onedayitwillmake
Copy link
Author

@xzyfer @mgreter Just curious if there was any movement on this, I implemented the .travis.yml modifications, should I just rebase?

@xzyfer
Copy link
Contributor

xzyfer commented Apr 14, 2015

@onedayitwillmake yes please rebase on master and resolve any conflicts.

It also looks like this branch has had a lot of merges with master which means it cannot be merged in it's current state. A rebase may help push out the unwanted commits, otherwise we'll need to find another way to clean up this branch.

We rely heavily on git forensics to track down bug and regressions. This requires a clean commit history.

@onedayitwillmake
Copy link
Author

@xzyfer Gotcha, makes sense.
Besides the one on the bottom, which other ones do you see have merges with master?

@xzyfer
Copy link
Contributor

xzyfer commented Apr 14, 2015

I can see commits from myself and @mgreter which don't belong here. These were presumably introduced in a merge.

screen shot 2015-04-14 at 10 37 52 am
screen shot 2015-04-14 at 10 38 03 am

@xzyfer
Copy link
Contributor

xzyfer commented Apr 19, 2015

@onedayitwillmake have you had a chance to clean up this PR? You can probably squash this down to a few commits.

@onedayitwillmake
Copy link
Author

@xzyfer I will give it another go tomorrow morning, you reckon I should just squash it to a few key commits and rebase from there?

@xzyfer
Copy link
Contributor

xzyfer commented Apr 21, 2015

@onedayitwillmake yes I do. However I expect you will into issues due to the merge commits.

@onedayitwillmake
Copy link
Author

@xzyfer Looks like something else broke on this one, saying I have a duplicate function however I'm not seeing that on my end. Maybe I'm just bad at pull-request, what do you suggest



// For every selector in RHS, see if we have /any/ selectors which are a super-selector of it
bool Selector_List::is_superselector_of(Sass::Selector_List *rhs) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is cause of the CI error. See line 501 above.

@xzyfer
Copy link
Contributor

xzyfer commented Apr 24, 2015

Impressive git work to fix this branch.

Please remove the debug code.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.8%) to 78.46% when pulling 74600d3 on onedayitwillmake:selector_functions into 20d8870 on sass:master.

@onedayitwillmake
Copy link
Author

@xzyfer Thanks for heads up, I removed them

@xzyfer xzyfer modified the milestones: 3.2.2, 3.3 May 1, 2015
@onedayitwillmake
Copy link
Author

@mgreter Any movement on this one?


for (size_t i = 0, L = extender->length(); i < L; ++i) {
// let's test this out
cerr << "REGISTERING EXTENSION REQUEST: " << (*extender)[i]->perform(&to_string) << " <- " << compound_sel->perform(&to_string) << endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug code?

@xzyfer
Copy link
Contributor

xzyfer commented May 3, 2015

@onedayitwillmake I've left some nitpick feedback for now. This will be a closer look when we're ready to start working on 3.3. Thanks heaps for all your work here, it's really appreciated.

One suggestion I have is to try to make the diff as clean as possible so we can focus on the changes that are relevant i.e. avoid unnecessary white changes, remove debug or commented out code

mgreter pushed a commit to mgreter/libsass that referenced this pull request May 12, 2015
@onedayitwillmake onedayitwillmake mentioned this pull request Jun 4, 2015
7 tasks
@xzyfer
Copy link
Contributor

xzyfer commented Jul 8, 2015

Superseded #1261

@xzyfer xzyfer closed this Jul 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants