Skip to content

Commit

Permalink
Merge e707bcc into a531ba2
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim de Beer committed Sep 30, 2016
2 parents a531ba2 + e707bcc commit 0f4946d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 18 deletions.
6 changes: 3 additions & 3 deletions lib/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ exports.properties = {
if (!val || typeof val !== 'string') { val = '' }
setTransform(val, store, node)
},
state (target, state, type, stamp, subs, tree, id, pid, store) {
var val = state && target.$ ? target.compute(state) : target.compute()
state (target, s, type, stamp, subs, tree, id, pid, store) {
var val = s && target.$ ? target.compute(s) : target.compute()
if (!val || typeof val !== 'string') { val = '' }
const node = getParent(type, stamp, subs, tree, pid)
setTransform(val, store, node)
if (node) { setTransform(val, store, node) }
}
}
}
Expand Down
18 changes: 5 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
"brisky-core": "^1.4.1",
"vigour-ua": "^2.0.3",
"vigour-util": "^3.0.0",
"babel-preset-es2015": "^6.6.0",
"babelify": "^7.3.0"
"bubleify": "0.5.1"
},
"devDependencies": {
"ducktape": "^1.0.0",
Expand All @@ -42,21 +41,14 @@
"istanbul": "^0.4.3",
"nodemon": "^1.9.1",
"pre-commit": "^1.1.3",
"standard": "^7.0.1",
"tap-difflet": "0.4.0",
"standard": "^8.1.0",
"tap-difflet": "0.6.0",
"tape": "^4.4.0",
"budo": "^8.2.2"
"budo": "^9.0.0"
},
"browserify": {
"transform": [
[
"babelify",
{
"presets": [
"es2015"
]
}
]
"bubleify"
]
},
"contributors": [
Expand Down
32 changes: 30 additions & 2 deletions test/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const test = require('tape')
const s = require('vigour-state/s')
const render = require('brisky-core/render')

test('transform - static', function (t) {
test('transform - static', (t) => {
const elem = render({
style: {
transform: {
Expand All @@ -17,7 +17,7 @@ test('transform - static', function (t) {
t.end()
})

test('transform - state', function (t) {
test('transform - state', (t) => {
const state = s({
x: -5,
y: 5,
Expand All @@ -36,3 +36,31 @@ test('transform - state', function (t) {
t.equals(elem.style.transform, 'translate3d(-5px, 5px, 0px) scale(0.1) rotate(5deg)', 'mixed state and static')
t.end()
})

test('transform - state - remove', (t) => {
const state = s({
a: {
y: 5
},
b: {},
field: '$root.a'
})
const elem = render({
field: {
$: 'field.$switch',
properties: {
a: {
style: {
transform: {
y: { $: 'y' }
}
}
}
}
}
}, state)
t.equals(elem.childNodes[0].childNodes[0].style.transform, 'translate3d(0, 5px, 0px)', 'intial')
state.set({ field: '$root.b' })
t.ok(true, 'should not crash on remove')
t.end()
})

0 comments on commit 0f4946d

Please sign in to comment.