| // create a simple finite state machine | ||
| function createFSM() { | ||
| return { | ||
| _stack: [], | ||
| enter: function(state) { | ||
| this._stack.push(state); | ||
| return this; | ||
| }, | ||
| leave: function(state) { | ||
| var stack = this._stack; | ||
| // if state is falsy or state equals to last item in stack | ||
| if(!state || stack[stack.length-1] === state) { | ||
| stack.pop(); | ||
| } | ||
| return this; | ||
| }, | ||
| get: function() { | ||
| var stack = this._stack; | ||
| return stack[stack.length - 1]; | ||
| }, | ||
| all: function() { | ||
| return this._stack; | ||
| }, | ||
| is: function(state) { | ||
| var stack = this._stack; | ||
| return stack[stack.length - 1] === state | ||
| } | ||
| } | ||
| } | ||
| module.exports = createFSM; |
@@ -49,4 +49,8 @@ // Regular | ||
| } | ||
| this.$watch(value, function(nvalue){ | ||
| for(var i in nvalue) if(nvalue.hasOwnProperty(i)){ | ||
| this.$watch(value, function(nvalue, ovalue){ | ||
| // remove styleProperty that are no longer in nvalue | ||
| for (var i in ovalue) if (ovalue.hasOwnProperty(i) && !nvalue.hasOwnProperty(i)) { | ||
| dom.css(elem, i, ''); | ||
| } | ||
| for(i in nvalue) if(nvalue.hasOwnProperty(i)){ | ||
| dom.css(elem, i, nvalue[i]); | ||
@@ -53,0 +57,0 @@ } |
@@ -86,2 +86,3 @@ // Regular | ||
| dom.on( elem, "change", handler ); | ||
@@ -106,6 +107,6 @@ if(parsed.get(self) === undefined && elem.value){ | ||
| // <input throttle r-model> | ||
| if(param[throttle] === true){ | ||
| if(param.throttle === true){ | ||
| throttle = 400; | ||
| }else{ | ||
| throttle = parseInt(param.throttle , 10) | ||
| throttle = parseInt(param.throttle, 10) | ||
| } | ||
@@ -120,3 +121,9 @@ } | ||
| // @TODO to fixed event | ||
| var isCompositing = false; | ||
| var handler = function (ev){ | ||
| if(isCompositing) return; | ||
| isCompositing = false; | ||
| var that = this; | ||
@@ -138,2 +145,11 @@ if(ev.type==='cut' || ev.type==='paste'){ | ||
| function onCompositionStart(){ | ||
| isCompositing = true; | ||
| } | ||
| function onCompositionEnd(ev){ | ||
| isCompositing = false; | ||
| handler.call(this,ev) | ||
| } | ||
| if(throttle && !lazy){ | ||
@@ -151,2 +167,8 @@ var preHandle = handler, tid; | ||
| }else{ | ||
| if(typeof CompositionEvent === 'function' ){ //lazy的情况不需要compositionend | ||
| elem.addEventListener("compositionstart", onCompositionStart ); | ||
| elem.addEventListener("compositionend", onCompositionEnd ); | ||
| } | ||
| if( hasInput){ | ||
@@ -153,0 +175,0 @@ elem.addEventListener("input", handler ); |
@@ -1,2 +0,2 @@ | ||
| // some nested operation in ast | ||
| // some nested operation in ast | ||
| // -------------------------------- | ||
@@ -27,3 +27,5 @@ | ||
| if(Array.isArray(node)){ | ||
| nodes.push.apply(nodes, node) | ||
| for (var j = 0, len1 = node.length; j < len1; j++){ | ||
| nodes.push(node[j]) | ||
| } | ||
| }else if(node) { | ||
@@ -99,3 +101,3 @@ nodes.push(node) | ||
| elements.push(node); | ||
| } | ||
| } | ||
| } | ||
@@ -102,0 +104,0 @@ return !all? elements[0]: elements; |
@@ -5,3 +5,3 @@ // simplest event emitter 60 lines | ||
| var fallbackEvent = { | ||
| destory: '$destory', | ||
| destroy: '$destroy', | ||
| update: '$update', | ||
@@ -8,0 +8,0 @@ init: '$init', |
+31
-45
| var _ = require("../util"); | ||
| var config = require("../config"); | ||
| var createFSM = require("./FSM"); | ||
@@ -33,6 +34,8 @@ // some custom tag will conflict with the Lexer progress | ||
| this.opts = opts || {}; | ||
| this.syntaxSets = createFSM(); | ||
| this.state = createFSM(); | ||
| this.map = this.opts.mode !== 2? map1: map2; | ||
| this.states = ["INIT"]; | ||
| this.syntaxSets.enter('INIT'); | ||
| if(opts && opts.expression){ | ||
| this.states.push("JST"); | ||
| this.syntaxSets.enter('JST'); | ||
| this.expression = true; | ||
@@ -49,3 +52,3 @@ } | ||
| str = str.trim(); | ||
| var tokens = [], split, test,mlen, token, state; | ||
| var tokens = [], split, test,mlen, token, syntax; | ||
| this.input = str, | ||
@@ -58,4 +61,4 @@ this.marks = 0; | ||
| i++ | ||
| state = this.state(); | ||
| split = this.map[state] | ||
| syntax = this.syntaxSets.get(); | ||
| split = this.map[syntax]; | ||
| test = split.TRUNK.exec(str); | ||
@@ -74,3 +77,3 @@ if(!test){ | ||
| tokens.push({type: 'EOF'}); | ||
| return tokens; | ||
@@ -104,6 +107,6 @@ } | ||
| case "<": | ||
| this.enter("TAG"); | ||
| this.syntaxSets.enter("TAG"); | ||
| break; | ||
| default: | ||
| this.enter("JST"); | ||
| this.syntaxSets.enter("JST"); | ||
| break; | ||
@@ -114,18 +117,3 @@ } | ||
| } | ||
| lo.enter = function(state){ | ||
| this.states.push(state) | ||
| return this; | ||
| } | ||
| lo.state = function(){ | ||
| var states = this.states; | ||
| return states[states.length-1]; | ||
| } | ||
| lo.leave = function(state){ | ||
| var states = this.states; | ||
| if(!state || states[states.length-1] === state) states.pop() | ||
| } | ||
| Lexer.setup = function(){ | ||
@@ -243,3 +231,3 @@ macro.END = config.END; | ||
| ENTER_JST: [/[^\x00<]*?(?={BEGIN})/, function(all){ | ||
| this.enter('JST'); | ||
| this.syntaxSets.enter('JST'); | ||
| if(all) return {type: 'TEXT', value: all} | ||
@@ -250,3 +238,3 @@ }], | ||
| ENTER_JST2: [/[^\x00]*?(?={BEGIN})/, function(all){ | ||
| this.enter('JST'); | ||
| this.syntaxSets.enter('JST'); | ||
| if(all) return {type: 'TEXT', value: all} | ||
@@ -256,3 +244,3 @@ }], | ||
| ENTER_TAG: [/[^\x00]*?(?=<[\w\/\!])/, function(all){ | ||
| this.enter('TAG'); | ||
| this.syntaxSets.enter('TAG'); | ||
| if(all) return {type: 'TEXT', value: all} | ||
@@ -263,10 +251,7 @@ }], | ||
| BODY_END: [/{SPACE}*{END}/, function(val){ | ||
| var sets = this.syntaxSets.all(), slen = sets.length; | ||
| var states = this.states, slen = states.length; | ||
| if(states[slen-2] === 'JST' ){ | ||
| this.leave('INIT'); | ||
| this.leave('JST'); | ||
| if(sets[slen-2] === 'JST'){ | ||
| this.syntaxSets.leave('INIT'); | ||
| this.syntaxSets.leave('JST'); | ||
| return {type: 'END'} | ||
@@ -290,3 +275,3 @@ } | ||
| TAG_CLOSE: [/<\/({NAME})[\r\n\f\t ]*>/, function(all, one){ | ||
| this.leave(); | ||
| this.syntaxSets.leave(); | ||
| return {type: 'TAG_CLOSE', value: one } | ||
@@ -297,3 +282,3 @@ }, 'TAG'], | ||
| TAG_ENTER_JST: [/(?={BEGIN})/, function(){ | ||
| this.enter('JST'); | ||
| this.syntaxSets.enter('JST'); | ||
| }, 'TAG'], | ||
@@ -303,3 +288,3 @@ | ||
| TAG_PUNCHOR: [/[\>\/=&]/, function(all){ | ||
| if(all === '>') this.leave(); | ||
| if(all === '>') this.syntaxSets.leave(); | ||
| return {type: all, value: all } | ||
@@ -316,3 +301,3 @@ }, 'TAG'], | ||
| TAG_COMMENT: [/<\!--([^\x00]*?)--\>/, function(all){ | ||
| this.leave() | ||
| this.syntaxSets.leave() | ||
| // this.leave('TAG') | ||
@@ -324,2 +309,3 @@ } ,'TAG'], | ||
| JST_OPEN: ['{BEGIN}#{SPACE}*({IDENT})', function(all, name){ | ||
| this.state.enter('JST_OPEN'); | ||
| return { | ||
@@ -332,3 +318,3 @@ type: 'OPEN', | ||
| JST_BODY_OPEN: ['{BEGIN}~{SPACE}*', function(all, name){ | ||
| this.enter('INIT'); | ||
| this.syntaxSets.enter('INIT'); | ||
| return { | ||
@@ -342,4 +328,5 @@ type: 'BODY_OPEN', | ||
| if(!this.markEnd || !this.marks ){ | ||
| this.firstEnterStart = false; | ||
| this.leave('JST'); | ||
| this.state.leave('JST_OPEN'); | ||
| this.state.leave('JST_EXPR_OPEN'); | ||
| this.syntaxSets.leave('JST'); | ||
| return {type: 'END'} | ||
@@ -352,3 +339,3 @@ }else{ | ||
| JST_CLOSE: [/{BEGIN}\s*\/({IDENT})\s*{END}/, function(all, one){ | ||
| this.leave('JST'); | ||
| this.syntaxSets.leave('JST'); | ||
| return { | ||
@@ -360,3 +347,3 @@ type: 'CLOSE', | ||
| JST_COMMENT: [/{BEGIN}\!([^\x00]*?)\!{END}/, function(){ | ||
| this.leave(); | ||
| this.syntaxSets.leave(); | ||
| }, 'JST'], | ||
@@ -366,8 +353,7 @@ JST_EXPR_OPEN: ['{BEGIN}',function(all, one){ | ||
| if(this.expression) return { type: this.markStart, value: this.markStart }; | ||
| if(this.firstEnterStart || this.marks){ | ||
| if(this.state.is('JST_OPEN') || this.state.is('JST_EXPR_OPEN') || this.marks){ | ||
| this.marks++ | ||
| this.firstEnterStart = false; | ||
| return { type: this.markStart, value: this.markStart }; | ||
| }else{ | ||
| this.firstEnterStart = true; | ||
| this.state.enter('JST_EXPR_OPEN'); | ||
| } | ||
@@ -374,0 +360,0 @@ } |
@@ -234,2 +234,3 @@ /** | ||
| } | ||
| if(typeof cfg.link !== 'function') cfg.link = NOOP; | ||
| return this | ||
@@ -236,0 +237,0 @@ } |
+1
-1
| { | ||
| "name": "regularjs", | ||
| "version": "0.6.0-beta.10", | ||
| "version": "0.6.0-beta.11", | ||
| "author": { | ||
@@ -5,0 +5,0 @@ "name": "leeluolee" |
+1
-4
@@ -1,6 +0,3 @@ | ||
| <a href="http://regularjs.github.io"> | ||
|  | ||
| </a> | ||
| [](http://regularjs.github.io) | ||
| # Regularjs | ||
@@ -7,0 +4,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
461543
1.13%44
2.33%11852
0.85%205
-1.44%74
17.46%