{"action":"created","issue":{"url":"https://api.github.com/repos/sass/libsass/issues/439","labels_url":"https://api.github.com/repos/sass/libsass/issues/439/labels{/name}","comments_url":"https://api.github.com/repos/sass/libsass/issues/439/comments","events_url":"https://api.github.com/repos/sass/libsass/issues/439/events","html_url":"https://github.com/sass/libsass/issues/439","id":37693993,"number":439,"title":"Placeholder selector issues","user":{"login":"errorx666","id":1048542,"avatar_url":"https://avatars.githubusercontent.com/u/1048542?v=3","gravatar_id":"","url":"https://api.github.com/users/errorx666","html_url":"https://github.com/errorx666","followers_url":"https://api.github.com/users/errorx666/followers","following_url":"https://api.github.com/users/errorx666/following{/other_user}","gists_url":"https://api.github.com/users/errorx666/gists{/gist_id}","starred_url":"https://api.github.com/users/errorx666/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/errorx666/subscriptions","organizations_url":"https://api.github.com/users/errorx666/orgs","repos_url":"https://api.github.com/users/errorx666/repos","events_url":"https://api.github.com/users/errorx666/events{/privacy}","received_events_url":"https://api.github.com/users/errorx666/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sass/libsass/labels/bug","name":"bug","color":"e11d21"},{"url":"https://api.github.com/repos/sass/libsass/labels/test+written","name":"test written","color":"bfe5bf"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2014-07-11T20:21:13Z","updated_at":"2015-01-12T06:33:37Z","closed_at":null,"body":"I have the following mixins designed to emulate `:nth-child(even)` and `:nth-child(odd)` in IE8.  I am having two problems that do not occur in the default Sass implementation:\r\n\r\n```scss\r\n@mixin odd( $selector: '*', $n: 50 ) {\r\n\t$local-sel: '&';\r\n\t$local-uniq: unique_id();\r\n\r\n\t#{$selector}:nth-child(odd) { @content }\r\n\r\n\t%#{$local-uniq} { @content; }\r\n\r\n\t#{$selector}:first-child {\r\n\t\t@for $i from 1 through $n {\r\n\t\t\t#{$local-sel} { @extend %#{$local-uniq}; }\r\n\r\n\t\t\t$local-sel: $local-sel + ' + ' + $selector + ' + ' + $selector;\r\n\r\n\t\t}\r\n\r\n\t}\r\n\r\n}\r\n\r\n@mixin even( $selector: '*', $n: 50 ) {\r\n\t$local-sel: '&';\r\n\t$local-uniq: unique_id();\r\n\r\n\t#{$selector}:nth-child(even) { @content }\r\n\r\n\t%#{$local-uniq} { @content; }\r\n\r\n\t#{$selector}:first-child + #{$selector} {\r\n\t\t@for $i from 1 through $n {\r\n\t\t\t#{$local-sel} { @extend %#{$local-uniq}; }\r\n\r\n\t\t\t$local-sel: $local-sel + ' + ' + $selector + ' + ' + $selector;\r\n\r\n\t\t}\r\n\r\n\t}\r\n\r\n}\r\n```\r\n\r\nAn example use-case is:\r\n```scss\r\nul > {\r\n  @include odd( li, 5 ) { background: #ccc;  }\r\n}\r\n```\r\nWhich in Sass 3.3.9 produces:\r\n```css\r\nul > li:nth-child(odd) {\r\n  background: #ccc;\r\n}\r\nul > li:first-child, ul > li:first-child + li + li, ul > li:first-child + li + li + li + li, ul > li:first-child + li + li + li + li + li + li, ul > li:first-child + li + li + li + li + li + li + li + li {\r\n  background: #ccc;\r\n}\r\n```\r\n\r\nIn LibSass I get: `source string:7: error: invalid selector after %unique-id`\r\n\r\n---\r\nThe unique ID is needed to stop successive invocations from using the same placeholder selector.\r\n\r\nIf I replace the unique ID, I get a successful compile, but the selectors do not match the Sass implementation:\r\n\r\n```scss\r\n@mixin odd( $selector: '*', $n: 50 ) {\r\n\t$local-sel: '&';\r\n\r\n\t#{$selector}:nth-child(odd) { @content }\r\n\r\n\t%foo { @content; }\r\n\r\n\t#{$selector}:first-child {\r\n\t\t@for $i from 1 through $n {\r\n\t\t\t#{$local-sel} { @extend %foo; }\r\n\r\n\t\t\t$local-sel: $local-sel + ' + ' + $selector + ' + ' + $selector;\r\n\r\n\t\t}\r\n\r\n\t}\r\n\r\n}\r\n\r\nul > {\r\n  @include odd( li, 5 ) { background: #ccc;  }\r\n}\r\n```\r\n\r\nExpected:\r\n```css\r\nul > li:nth-child(odd) {\r\n  background: #ccc;\r\n}\r\nul > li:first-child, ul > li:first-child + li + li, ul > li:first-child + li + li + li + li, ul > li:first-child + li + li + li + li + li + li, ul > li:first-child + li + li + li + li + li + li + li + li {\r\n  background: #ccc;\r\n}\r\n```\r\n\r\nActual:\r\n```css\r\nul > li:nth-child(odd) {\r\n  background: #ccc; }\r\nul > ul > li:first-child, ul > ul > li:first-child + li + li, ul > ul > li:first-child + li + li + li + li, ul > ul > li:first-child + li + li + li + li + li + li, ul > ul > li:first-child + li + li + li + li + li + li + li + li {\r\n  background: #ccc; }\r\n```\r\n\r\nNote the `ul > ul >` which should not appear.  This may be related to the ampersand in the selector."},"comment":{"url":"https://api.github.com/repos/sass/libsass/issues/comments/69533765","html_url":"https://github.com/sass/libsass/issues/439#issuecomment-69533765","issue_url":"https://api.github.com/repos/sass/libsass/issues/439","id":69533765,"user":{"login":"xzyfer","id":579928,"avatar_url":"https://avatars.githubusercontent.com/u/579928?v=3","gravatar_id":"","url":"https://api.github.com/users/xzyfer","html_url":"https://github.com/xzyfer","followers_url":"https://api.github.com/users/xzyfer/followers","following_url":"https://api.github.com/users/xzyfer/following{/other_user}","gists_url":"https://api.github.com/users/xzyfer/gists{/gist_id}","starred_url":"https://api.github.com/users/xzyfer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xzyfer/subscriptions","organizations_url":"https://api.github.com/users/xzyfer/orgs","repos_url":"https://api.github.com/users/xzyfer/repos","events_url":"https://api.github.com/users/xzyfer/events{/privacy}","received_events_url":"https://api.github.com/users/xzyfer/received_events","type":"User","site_admin":false},"created_at":"2015-01-12T06:33:37Z","updated_at":"2015-01-12T06:33:37Z","body":"It's worth mentioning `unique-id` has now been implemented but it is not the cause of the issue."}}