Skip to content

Commit

Permalink
Merge pull request #7 from yosssi/fix-parent-reference
Browse files Browse the repository at this point in the history
Fixed the parent reference function
  • Loading branch information
yosssi committed Oct 7, 2014
2 parents 9704ea6 + bc02c10 commit 513d235
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 deletions.
2 changes: 1 addition & 1 deletion e2e_test.go
Expand Up @@ -11,7 +11,7 @@ import (
func Test_e2e(t *testing.T) {
var wg sync.WaitGroup

for i := 1; i <= 11; i++ {
for i := 1; i <= 12; i++ {
idx := strconv.Itoa(i)

gcssPath := "test/e2e/actual/" + strings.Repeat("0", 4-len(idx)) + idx + ".gcss"
Expand Down
7 changes: 3 additions & 4 deletions selector.go
Expand Up @@ -75,13 +75,12 @@ func (sel *selector) names() string {
bf.WriteString(comma)
}

bf.WriteString(parentS)

s = strings.TrimSpace(s)

if strings.HasPrefix(s, ampersand) {
bf.WriteString(strings.TrimPrefix(s, ampersand))
if strings.Index(s, ampersand) != -1 {
bf.WriteString(strings.Replace(s, ampersand, parentS, -1))
} else {
bf.WriteString(parentS)
bf.WriteString(space)
bf.WriteString(s)
}
Expand Down
38 changes: 38 additions & 0 deletions test/e2e/actual/0012.gcss
@@ -0,0 +1,38 @@
// Various types of a parent reference
div
font-size: 12px
&:hover
color: blue
& span
font-size: 14px
a
color: red
header &
font-weight: bold
span
background-color: white
section
font-size: 11px
& a
color: yellow
span &
color: black

.class1, .class2
font-size: 12px
&:hover
color: blue
& span
font-size: 14px
a
color: red
header &
font-weight: bold
span
background-color: white
section
font-size: 11px
& a
color: yellow
span &
color: black
1 change: 1 addition & 0 deletions test/e2e/expected/0012.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion version.go
@@ -1,4 +1,4 @@
package gcss

// Version is the version of GCSS.
const Version = "GCSS 0.0.5"
const Version = "GCSS 0.0.6"

0 comments on commit 513d235

Please sign in to comment.