Comparing version 0.6.0 to 0.10.0
@@ -8,6 +8,37 @@ var homunculus=function(){var _0=require('homunculus');return _0.hasOwnProperty("default")?_0["default"]:_0}(); | ||
var idx; | ||
function parse(node, option) { | ||
var res = {}; | ||
idx = 0; | ||
var res = { | ||
default: {} | ||
}; | ||
node.leaves().forEach(function(leaf, i) { | ||
styleset(leaf, i, res, option); | ||
if(leaf.name() == Node.STYLESET) { | ||
styleset(leaf, res.default, option); | ||
} | ||
else if(leaf.name() == Node.MEDIA) { | ||
res.media = res.media || []; | ||
var item = {}; | ||
var qlist = leaf.leaf(1); | ||
qlist.leaves().forEach(function(leaf) { | ||
if(leaf.name() == Node.MEDIAQUERY) { | ||
query(leaf, item); | ||
} | ||
}); | ||
var block = leaf.last(); | ||
var leaves = block.leaves(); | ||
if(leaves.length > 2) { | ||
var style = {}; | ||
for(var i = 1, len = leaves.length - 1; i < len; i++) { | ||
styleset(leaves[i], style, option); | ||
} | ||
item.style = style; | ||
} | ||
if(item.style) { | ||
res.media.push(item); | ||
} | ||
} | ||
}); | ||
@@ -17,5 +48,27 @@ return res; | ||
function styleset(node, i, res, option) { | ||
function query(node, item) { | ||
var leaves = node.leaves(); | ||
var query = []; | ||
leaves.forEach(function(leaf) { | ||
if(leaf.name() == Node.EXPR) { | ||
var expr = []; | ||
leaf.leaves().forEach(function(item) { | ||
if(item.name() == Node.KEY || item.name() == Node.VALUE) { | ||
expr.push(join(item, true)); | ||
} | ||
}); | ||
//可能只有key或者k/v都有,以String/Array格式区分 | ||
if(expr.length) { | ||
query.push(expr.length > 1 ? expr : expr[0]); | ||
} | ||
} | ||
}); | ||
item.query = item.query || []; | ||
item.query.push(query); | ||
} | ||
function styleset(node, res, option) { | ||
var sels = selectors(node.first()); | ||
var styles = block(node.last()); | ||
var i = idx++; | ||
sels.forEach(function(sel) { | ||
@@ -22,0 +75,0 @@ record(sel, i, styles, res, option); |
{ | ||
"name": "jaw", | ||
"version": "0.6.0", | ||
"version": "0.10.0", | ||
"description": "Parasitize CSS to JSX for migi", | ||
@@ -33,3 +33,3 @@ "maintainers": [ | ||
"dependencies": { | ||
"homunculus": "~0.10.3" | ||
"homunculus": "~0.10.4" | ||
}, | ||
@@ -50,5 +50,5 @@ "devDependencies": { | ||
"engines": { | ||
"node": ">= 0.4.2" | ||
"node": ">= 4.2" | ||
}, | ||
"readmeFilename": "README.md" | ||
} |
@@ -8,6 +8,37 @@ import homunculus from 'homunculus'; | ||
var idx; | ||
function parse(node, option) { | ||
var res = {}; | ||
idx = 0; | ||
var res = { | ||
default: {} | ||
}; | ||
node.leaves().forEach(function(leaf, i) { | ||
styleset(leaf, i, res, option); | ||
if(leaf.name() == Node.STYLESET) { | ||
styleset(leaf, res.default, option); | ||
} | ||
else if(leaf.name() == Node.MEDIA) { | ||
res.media = res.media || []; | ||
var item = {}; | ||
var qlist = leaf.leaf(1); | ||
qlist.leaves().forEach(function(leaf) { | ||
if(leaf.name() == Node.MEDIAQUERY) { | ||
query(leaf, item); | ||
} | ||
}); | ||
var block = leaf.last(); | ||
var leaves = block.leaves(); | ||
if(leaves.length > 2) { | ||
var style = {}; | ||
for(var i = 1, len = leaves.length - 1; i < len; i++) { | ||
styleset(leaves[i], style, option); | ||
} | ||
item.style = style; | ||
} | ||
if(item.style) { | ||
res.media.push(item); | ||
} | ||
} | ||
}); | ||
@@ -17,5 +48,27 @@ return res; | ||
function styleset(node, i, res, option) { | ||
function query(node, item) { | ||
var leaves = node.leaves(); | ||
var query = []; | ||
leaves.forEach(function(leaf) { | ||
if(leaf.name() == Node.EXPR) { | ||
var expr = []; | ||
leaf.leaves().forEach(function(item) { | ||
if(item.name() == Node.KEY || item.name() == Node.VALUE) { | ||
expr.push(join(item, true)); | ||
} | ||
}); | ||
//可能只有key或者k/v都有,以String/Array格式区分 | ||
if(expr.length) { | ||
query.push(expr.length > 1 ? expr : expr[0]); | ||
} | ||
} | ||
}); | ||
item.query = item.query || []; | ||
item.query.push(query); | ||
} | ||
function styleset(node, res, option) { | ||
var sels = selectors(node.first()); | ||
var styles = block(node.last()); | ||
var i = idx++; | ||
sels.forEach(function(sel) { | ||
@@ -22,0 +75,0 @@ record(sel, i, styles, res, option); |
@@ -8,6 +8,37 @@ define(function(require, exports, module){var homunculus=function(){var _0=require('homunculus');return _0.hasOwnProperty("default")?_0["default"]:_0}(); | ||
var idx; | ||
function parse(node, option) { | ||
var res = {}; | ||
idx = 0; | ||
var res = { | ||
default: {} | ||
}; | ||
node.leaves().forEach(function(leaf, i) { | ||
styleset(leaf, i, res, option); | ||
if(leaf.name() == Node.STYLESET) { | ||
styleset(leaf, res.default, option); | ||
} | ||
else if(leaf.name() == Node.MEDIA) { | ||
res.media = res.media || []; | ||
var item = {}; | ||
var qlist = leaf.leaf(1); | ||
qlist.leaves().forEach(function(leaf) { | ||
if(leaf.name() == Node.MEDIAQUERY) { | ||
query(leaf, item); | ||
} | ||
}); | ||
var block = leaf.last(); | ||
var leaves = block.leaves(); | ||
if(leaves.length > 2) { | ||
var style = {}; | ||
for(var i = 1, len = leaves.length - 1; i < len; i++) { | ||
styleset(leaves[i], style, option); | ||
} | ||
item.style = style; | ||
} | ||
if(item.style) { | ||
res.media.push(item); | ||
} | ||
} | ||
}); | ||
@@ -17,5 +48,27 @@ return res; | ||
function styleset(node, i, res, option) { | ||
function query(node, item) { | ||
var leaves = node.leaves(); | ||
var query = []; | ||
leaves.forEach(function(leaf) { | ||
if(leaf.name() == Node.EXPR) { | ||
var expr = []; | ||
leaf.leaves().forEach(function(item) { | ||
if(item.name() == Node.KEY || item.name() == Node.VALUE) { | ||
expr.push(join(item, true)); | ||
} | ||
}); | ||
//可能只有key或者k/v都有,以String/Array格式区分 | ||
if(expr.length) { | ||
query.push(expr.length > 1 ? expr : expr[0]); | ||
} | ||
} | ||
}); | ||
item.query = item.query || []; | ||
item.query.push(query); | ||
} | ||
function styleset(node, res, option) { | ||
var sels = selectors(node.first()); | ||
var styles = block(node.last()); | ||
var i = idx++; | ||
sels.forEach(function(sel) { | ||
@@ -22,0 +75,0 @@ record(sel, i, styles, res, option); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
134577
1297
Updatedhomunculus@~0.10.4