homunculus
Advanced tools
Comparing version 0.9.3 to 0.9.4
if(typeof define === 'function' && (define.amd || define.cmd)) { | ||
define(function(require, exports, module) { | ||
module.exports = require('./web/Homunculus'); | ||
module.exports = require('./web/homunculus'); | ||
}); | ||
} | ||
else { | ||
module.exports = require('./src/Homunculus'); | ||
module.exports = require('./src/homunculus'); | ||
} |
{ | ||
"name": "homunculus", | ||
"version": "0.9.3", | ||
"version": "0.9.4", | ||
"description": "A lexer&parser by Javascript", | ||
@@ -5,0 +5,0 @@ "maintainers": [ |
@@ -25,2 +25,21 @@ var character = require('../util/character'); | ||
var SELF_CLOSE = { | ||
'img': true, | ||
'meta': true, | ||
'link': true, | ||
'br': true, | ||
'basefont': true, | ||
'base': true, | ||
'col': true, | ||
'embed': true, | ||
'frame': true, | ||
'hr': true, | ||
'input': true, | ||
'keygen': true, | ||
'area': true, | ||
'param': true, | ||
'source': true, | ||
'track': true | ||
}; | ||
var JSXLexer = Lexer.extend(function(rule) { | ||
@@ -35,2 +54,3 @@ Lexer.call(this, rule); | ||
this.jStack = []; //当{开始时++,减少时--,以此得知js部分结束回归jsx | ||
this.selfClose = false; //当前jsx标签是否是自闭和 | ||
}, | ||
@@ -71,2 +91,5 @@ scan: function(temp) { | ||
else if(this.peek == '>') { | ||
if(this.selfClose) { | ||
this.error('self-close tag needs />'); | ||
} | ||
this.state = false; | ||
@@ -263,2 +286,8 @@ //>结束时,html深度若为0,说明html状态结束,或者栈最后一个计数器为0,也结束 | ||
this.dealToken(token, matchLen, 0, temp); | ||
//自闭和没有.和: | ||
if(SELF_CLOSE.hasOwnProperty(token.content().toLowerCase())) { | ||
this.selfClose = true; | ||
return; | ||
} | ||
this.selfClose = false; | ||
var c = this.code.charAt(this.index); | ||
@@ -320,3 +349,5 @@ if(c == '.') { | ||
} | ||
}).statics({ | ||
SELF_CLOSE: SELF_CLOSE | ||
}); | ||
module.exports = JSXLexer; |
@@ -5,2 +5,3 @@ var Es6Parser = require('../es6/Parser'); | ||
var character = require('../../util/character'); | ||
var Lexer = require('../../lexer/JSXLexer'); | ||
@@ -238,4 +239,6 @@ var Parser = Es6Parser.extend(function(lexer) { | ||
} | ||
}).statics({ | ||
SELF_CLOSE: Lexer.SELF_CLOSE | ||
}); | ||
module.exports = Parser; |
@@ -25,2 +25,21 @@ define(function(require, exports, module) {var character = require('../util/character'); | ||
var SELF_CLOSE = { | ||
'img': true, | ||
'meta': true, | ||
'link': true, | ||
'br': true, | ||
'basefont': true, | ||
'base': true, | ||
'col': true, | ||
'embed': true, | ||
'frame': true, | ||
'hr': true, | ||
'input': true, | ||
'keygen': true, | ||
'area': true, | ||
'param': true, | ||
'source': true, | ||
'track': true | ||
}; | ||
var JSXLexer = Lexer.extend(function(rule) { | ||
@@ -35,2 +54,3 @@ Lexer.call(this, rule); | ||
this.jStack = []; //当{开始时++,减少时--,以此得知js部分结束回归jsx | ||
this.selfClose = false; //当前jsx标签是否是自闭和 | ||
}, | ||
@@ -71,2 +91,5 @@ scan: function(temp) { | ||
else if(this.peek == '>') { | ||
if(this.selfClose) { | ||
this.error('self-close tag needs />'); | ||
} | ||
this.state = false; | ||
@@ -263,2 +286,8 @@ //>结束时,html深度若为0,说明html状态结束,或者栈最后一个计数器为0,也结束 | ||
this.dealToken(token, matchLen, 0, temp); | ||
//自闭和没有.和: | ||
if(SELF_CLOSE.hasOwnProperty(token.content().toLowerCase())) { | ||
this.selfClose = true; | ||
return; | ||
} | ||
this.selfClose = false; | ||
var c = this.code.charAt(this.index); | ||
@@ -320,3 +349,5 @@ if(c == '.') { | ||
} | ||
}).statics({ | ||
SELF_CLOSE: SELF_CLOSE | ||
}); | ||
module.exports = JSXLexer;}); |
@@ -5,2 +5,3 @@ define(function(require, exports, module) {var Es6Parser = require('../es6/Parser'); | ||
var character = require('../../util/character'); | ||
var Lexer = require('../../lexer/JSXLexer'); | ||
@@ -238,4 +239,6 @@ var Parser = Es6Parser.extend(function(lexer) { | ||
} | ||
}).statics({ | ||
SELF_CLOSE: Lexer.SELF_CLOSE | ||
}); | ||
module.exports = Parser;}); |
Sorry, the diff of this file is not supported yet
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
1285194
19243