Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b90fe69
added fallbacks test to fn rules
kof Sep 18, 2018
2989e27
only call onChangeValue if plugins: true
kof Sep 18, 2018
dfbb767
enable removing props from fn rules
kof Sep 18, 2018
2296958
shorter syntax with coercion
kof Sep 18, 2018
bdd1ddf
Merge branch 'master' into dynamic-values-full-syntax
kof Sep 26, 2018
421d42b
wip full syntax support
kof Oct 9, 2018
901ae2f
Merge branch 'master' into dynamic-values-full-syntax
kof Oct 9, 2018
79228d2
restore browsers.json
kof Oct 9, 2018
3583f32
changelog
kof Oct 9, 2018
9a6a1e0
move hook call to the core
kof Oct 10, 2018
49cc07f
isProcessed flag explanation
kof Oct 10, 2018
7e5eca9
added tests to fn rules
kof Oct 10, 2018
abfafa8
remove media rule as a function test case
kof Oct 11, 2018
c5fdf05
added a test for #796, as part of #682
kof Oct 11, 2018
a70b3e2
tests for compose plugin
kof Oct 11, 2018
54f2b7f
observables
kof Oct 11, 2018
220bb42
move fn values docs
kof Oct 11, 2018
d5b2794
wording
kof Oct 11, 2018
171902b
Added tests for using jss-plugin-syntax-expand with function rules an…
Oct 13, 2018
0e53702
Skip fn values with jss-expand for now
Oct 13, 2018
efede57
move container rules update to the core
kof Oct 14, 2018
59f5ccc
optimize onProcessStyle
kof Oct 14, 2018
b17c63d
put variables in the right scope
kof Oct 14, 2018
7a32f09
changelog
kof Oct 14, 2018
6bb5bbd
Merge branch 'master' into dynamic-values-full-syntax
kof Oct 15, 2018
59fa73d
Update changelog.md
kof Oct 15, 2018
2c04dd7
process: true always
kof Oct 15, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
## Next / 2018-09-16

- Fix multiple cases where linking CSS rules didn't work (#815, #710, #664)
- Function values and function rules support now fallbacks, media queries, nesting, global styles (#682)
- Added support for Typed CSSOM values

### Breaking changes

- Observables, function values and rules are now standalone packages, not part of the core. They are still part of the default preset though.
- Function values and rules apply plugins by default now, which means they are slower by default. To speed them up use `sheet.update(data, {process: false})` (#682)
- Observables will not apply plugins by default now, to make them even faster. If you want them to use plugins, can use an option when using the plugin: `jss.use(pluginObservable({process: true}))` (#682)
- Function values, rules and observables apply plugins by default now, which means they can support all plugin defined syntaxes, but they are also slower by default. To speed them up use `sheet.update(data, {process: false})` for fn values/rules and `jss.use(pluginObservable({process: false}))` when setting up observables plugin. (#682)

## 9.8.7 / 2018-06-24

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ describe('jss-plugin-syntax-rule-value-observable: rules', () => {
sheet = jss
.createStyleSheet(
{
div: new Observable(obs => {
a: new Observable(obs => {
obs.next({display: 'block'})
observer = obs
})
Expand All @@ -163,28 +163,37 @@ describe('jss-plugin-syntax-rule-value-observable: rules', () => {
observer.next({display: 'inline-block'})

expect(sheet.toString()).to.be(stripIndent`
.div-id {
.a-id {
display: inline-block;
}
`)
})

it('should not process props or values', () => {
jss = create(settings).use(
pluginObservable({process: false}),
pluginDefaultUnit(),
pluginCamelCase()
)
sheet = jss.createStyleSheet(
{
a: new Observable(obs => {
observer = obs
})
},
{link: true}
)
observer.next({marginLeft: 20})

expect(sheet.toString()).to.be(stripIndent`
.div-id {
.a-id {
marginLeft: 20;
}
`)
})

it('should process props and values', () => {
jss = create(settings).use(
pluginObservable({process: true}),
pluginDefaultUnit(),
pluginCamelCase()
)
jss = create(settings).use(pluginObservable(), pluginDefaultUnit(), pluginCamelCase())
sheet = jss.createStyleSheet(
{
a: new Observable(obs => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ describe('jss-plugin-syntax-rule-value-observable: values', () => {
})

it('should not process value', () => {
jss = create(settings).use(pluginObservable({process: false}), pluginDefaultUnit())
sheet = jss.createStyleSheet(
{
a: {
height: new Observable(obs => {
observer = obs
})
}
},
{link: true}
)

observer.next(20)

expect(sheet.toString()).to.be(stripIndent`
Expand All @@ -74,7 +86,7 @@ describe('jss-plugin-syntax-rule-value-observable: values', () => {
})

it('should process the value', () => {
jss = create(settings).use(pluginObservable({process: true}), pluginDefaultUnit())
jss = create(settings).use(pluginObservable(), pluginDefaultUnit())
sheet = jss.createStyleSheet(
{
a: {
Expand Down
16 changes: 8 additions & 8 deletions packages/jss/.size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"dist/jss.js": {
"bundled": 54280,
"bundled": 54282,
"minified": 20204,
"gzipped": 6074
"gzipped": 6078
},
"dist/jss.min.js": {
"bundled": 53404,
"bundled": 53406,
"minified": 19591,
"gzipped": 5757
"gzipped": 5761
},
"dist/jss.cjs.js": {
"bundled": 48003,
"bundled": 48005,
"minified": 20648,
"gzipped": 5818
"gzipped": 5820
},
"dist/jss.esm.js": {
"bundled": 47546,
"bundled": 47548,
"minified": 20276,
"gzipped": 5732,
"gzipped": 5735,
"treeshaked": {
"rollup": {
"code": 17369,
Expand Down
2 changes: 1 addition & 1 deletion packages/jss/src/rules/StyleRule.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default class StyleRule implements BaseRule {
if (!force && this.style[name] === value) return this

let newValue = value
if (options && options.process === true) {
if (!options || options.process !== false) {
newValue = this.options.jss.plugins.onChangeValue(value, name, this)
}

Expand Down
8 changes: 4 additions & 4 deletions packages/jss/tests/integration/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,13 @@ describe('Integration: plugins', () => {
})

it('should be executed just once', () => {
sheet.getRule('a').prop('color', 'green', {process: true})
sheet.getRule('a').prop('color', 'green')
expect(executed).to.be(1)
})

it('should receive correct arguments', () => {
const rule = sheet.getRule('a')
rule.prop('color', 'green', {process: true})
rule.prop('color', 'green')
expect(receivedValue).to.be('green')
expect(receivedProp).to.be('color')
expect(receivedRule).to.be(rule)
Expand All @@ -265,7 +265,7 @@ describe('Integration: plugins', () => {
color: red;
}
`)
sheet.getRule('a').prop('color', 'green', {process: true})
sheet.getRule('a').prop('color', 'green')
expect(sheet.toString()).to.be(stripIndent`
.a-id {
color: green;
Expand All @@ -276,7 +276,7 @@ describe('Integration: plugins', () => {
it('should pass the new value to the next hook', () => {
jss.use({onChangeValue: value => `${value}-first`})
jss.use({onChangeValue: value => `${value}-second`})
sheet.getRule('a').prop('color', 'green', {process: true})
sheet.getRule('a').prop('color', 'green')
expect(sheet.toString()).to.be(stripIndent`
.a-id {
color: green-first-second;
Expand Down
8 changes: 4 additions & 4 deletions packages/jss/tests/integration/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,28 +468,28 @@ describe('Integration: rules', () => {
it("should not use null when prop wasn't defined before", () => {
jss.use({onChangeValue: () => null})
const rule = jss.createRule()
rule.prop('abc', 'red', {process: true})
rule.prop('abc', 'red')
expect('abc' in rule.style).to.be(false)
})

it("should not use undefined when prop wasn't defined before", () => {
jss.use({onChangeValue: () => undefined})
const rule = jss.createRule()
rule.prop('abc', 'red', {process: true})
rule.prop('abc', 'red')
expect('abc' in rule.style).to.be(false)
})

it('should use null to remove the prop when it was defined before', () => {
jss.use({onChangeValue: () => null})
const rule = jss.createRule({color: 'red'})
rule.prop('color', 'anything', {process: true})
rule.prop('color', 'anything')
expect('color' in rule.style).to.be(false)
})

it('should use undefined to remove the prop when it was defined before', () => {
jss.use({onChangeValue: () => undefined})
const rule = jss.createRule({color: 'red'})
rule.prop('color', 'anything', {process: true})
rule.prop('color', 'anything')
expect('color' in rule.style).to.be(false)
})
})
Expand Down