bem-bl-xjst
Advanced tools
Comparing version
@@ -167,3 +167,3 @@ var ometajs = require('ometajs'), | ||
ContextReplacer.prototype.isHash = function isHash(node) { | ||
ContextReplacer.prototype.isHash = function isHash(node, kind) { | ||
var val = node.init; | ||
@@ -173,6 +173,10 @@ if (!val) | ||
if (val.type !== 'ObjectExpression' || val.properties.length !== 3) | ||
if (val.type !== 'ObjectExpression') | ||
return false; | ||
var props = val.properties; | ||
if (kind === 'legacy') | ||
if (props.length !== 3) | ||
return false; | ||
return props.every(function(prop) { | ||
@@ -182,7 +186,12 @@ var name = prop.key.name; | ||
if ((name === 'n' || name === 'm') && val.type === 'ObjectExpression') | ||
return true; | ||
if (name === 'd' && val.type === 'FunctionExpression') | ||
return true; | ||
return false; | ||
if (kind === 'legacy') { | ||
if ((name === 'n' || name === 'm') && val.type === 'ObjectExpression') | ||
return true; | ||
if (name === 'd' && val.type === 'FunctionExpression') | ||
return true; | ||
return false; | ||
} else { | ||
return val.type === 'FunctionExpression' || | ||
val.type === 'Identifier'; | ||
} | ||
}); | ||
@@ -217,6 +226,12 @@ }; | ||
ContextReplacer.prototype.isMap = function isMap(node) { | ||
return this.applyc === null && | ||
node.type === 'VariableDeclarator' && | ||
/^__(h|\$m)\d+$/.test(node.id && node.id.name) && | ||
this.isHash(node); | ||
if (this.applyc !== null || node.type !== 'VariableDeclarator') | ||
return false; | ||
if (/^__(h|\$m)\d+$/.test(node.id && node.id.name)) | ||
return this.isHash(node, 'legacy'); | ||
if (/^__h\d+_\w$/.test(node.id && node.id.name)) | ||
return this.isHash(node, 'new'); | ||
return false; | ||
}; | ||
@@ -274,3 +289,3 @@ | ||
enter: function(node) { | ||
if (node.type === 'Identifier' && /^__(h|\$m)\d+$/.test(node.name)) { | ||
if (node.type === 'Identifier' && /^__(h|\$m)\d+(_\w)?$/.test(node.name)) { | ||
match = true; | ||
@@ -277,0 +292,0 @@ this['break'](); |
{ | ||
"name": "bem-bl-xjst", | ||
"version": "2.0.3", | ||
"version": "2.1.1", | ||
"description": "xjst compiler for bem-bl", | ||
"main": "lib/bemhtml.js", | ||
"dependencies": { | ||
"xjst": "~0.5.24", | ||
"xjst": "~0.10.0", | ||
"ometajs": "~3.3.5", | ||
@@ -9,0 +9,0 @@ "estraverse": "~1.5.0", |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
43984
2.39%415
2.72%0
-100%+ Added
- Removed
Updated