Skip to content

Commit

Permalink
fixed bug when plugins called twice on createStyleSheet #258
Browse files Browse the repository at this point in the history
  • Loading branch information
kof committed Jul 5, 2016
1 parent cf28cdb commit d7c8b8e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
4 changes: 4 additions & 0 deletions history.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.0.3 / 2016-07-05

- fixed bug when plugins called twice on createStyleSheet #258

## 4.0.2 / 2016-06-28

- allow adding rules to a detached sheet #253
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jss",
"description": "A lib for generating Style Sheets with JavaScript.",
"version": "4.0.2",
"version": "4.0.3",
"author": {
"name": "Oleg Slobodskoi",
"email": "oleg008@gmail.com"
Expand Down
3 changes: 2 additions & 1 deletion src/StyleSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export default class StyleSheet {
for (const name in rules) {
this.createAndRegisterRule(name, rules[name])
}
for (const name in this.rules) {

for (const name in rules) {
this.options.jss.plugins.run(this.rules[name])
}
}
Expand Down
18 changes: 17 additions & 1 deletion tests/integration/jss.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,24 @@ describe('Integration: jss', () => {
})

describe('.use()', () => {
describe('.createStyleSheet()', () => {
it('should pass rule correctly', () => {
let receivedRule
let executed = 0
jss.use(rule => {
receivedRule = rule
executed++
})
const sheet = jss.createStyleSheet({
a: {float: 'left'}
})
expect(sheet.getRule('a')).to.be(receivedRule)
expect(executed).to.be(1)
})
})

describe('.createRule()', () => {
it('should pass correct rule to the plugin', () => {
it('should pass rule correctly', () => {
let receivedRule
let executed = 0
jss.use(rule => {
Expand Down

0 comments on commit d7c8b8e

Please sign in to comment.