Skip to content

Commit 3b89cd4

Browse files
committed
Merge pull request #23 from iamvdo/master
Fixed: create `before` property on `first` element, only if defined
2 parents 44eb074 + 264286a commit 3b89cd4

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ function addIgnoredAtRulesOnTop(styles, ignoredAtRules) {
109109
styles.nodes.unshift(ignoredAtRule)
110110
}
111111

112-
first.before = "\n\n" + first.before
112+
if (first) {
113+
first.before = "\n\n" + first.before
114+
}
113115
}
114116
}
115117

test/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ test("@import", function(t) {
5353

5454
compareFixtures(t, "modules", "should be able to consume npm package or local modules", {root: __dirname, path: importsDir})
5555

56+
var base = "@import url(http://)"
57+
t.equal(
58+
postcss()
59+
.use(atImport())
60+
.process(base)
61+
.css.trim(),
62+
base,
63+
"should not fail with only one absolute import"
64+
)
65+
5666
t.end()
5767
})
5868

0 commit comments

Comments
 (0)