Skip to content

Commit

Permalink
Merge pull request #111 from vigour-io/feature/style-type
Browse files Browse the repository at this point in the history
expose style as type and use state.key as name when target.key === de…
  • Loading branch information
youzi committed Dec 12, 2016
2 parents baaba20 + fd649d5 commit 4c015f8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
8 changes: 7 additions & 1 deletion lib/property/html.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const parent = require('../render/dom/parent')

exports.props = {
exports.types = {
html: {
type: 'element',
render: {
Expand Down Expand Up @@ -34,3 +34,9 @@ exports.props = {
}
}
}

exports.props = {
html: {
type: 'html'
}
}
13 changes: 8 additions & 5 deletions lib/property/style/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ const { property } = require('../../render/static')
const ua = require('vigour-ua/navigator')

exports.types = {
style: require('./type')
}

exports.props = {
styleProp: require('./type'),
style: {
type: 'property',
render: {
Expand All @@ -30,7 +27,7 @@ exports.props = {
require('./transform')
],
props: {
default: { type: 'style' },
default: { type: 'styleProp' },
order: {
// put ua info on top for server or from render for example
// or add both for now
Expand All @@ -39,3 +36,9 @@ exports.props = {
}
}
}

exports.props = {
style: {
type: 'style'
}
}
8 changes: 4 additions & 4 deletions lib/property/style/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ exports.render = {
static (target, pnode) {
pnode.style[target.name || target.key] = target.compute()
},
state (target, s, type, subs, tree, id, pid) {
state (t, s, type, subs, tree, id, pid) {
if (type !== 'remove') {
const pnode = parent(tree, pid)
pnode.style[target.name || target.key] = s
? target.compute(s, s)
: target.compute()
pnode.style[t.name || (t.key !== 'default' ? t.key : s.key)] = s
? t.compute(s, s)
: t.compute()
}
}
}

0 comments on commit 4c015f8

Please sign in to comment.