+24
-7
@@ -180,6 +180,12 @@ /*jshint -W082 */ | ||
| // return node[key], if none exists, attach one with unique value | ||
| function ensureId(node, key) { | ||
| return typeof node[key] !== 'undefined' ? | ||
| node[key] : | ||
| (node[key] = _.uid()); | ||
| } | ||
| dom.on = function(node, type, handler){ | ||
| var types = type.split(' '); | ||
| handler.real = function(ev){ | ||
| var real = function(ev){ | ||
| var $event = new Event(ev); | ||
@@ -189,5 +195,16 @@ $event.origin = node; | ||
| } | ||
| var nodeId = ensureId(node, '_nid'); | ||
| handler._events = handler._events || {}; | ||
| types.forEach(function(type){ | ||
| type = fixEventName(node, type); | ||
| addEvent(node, type, handler.real); | ||
| var cacheKey = nodeId + '-' + type; | ||
| if(!handler._events[cacheKey]) { | ||
| handler._events[cacheKey] = real; | ||
| } | ||
| addEvent(node, type, handler._events[cacheKey]); | ||
| }); | ||
@@ -198,6 +215,9 @@ return dom; | ||
| var types = type.split(' '); | ||
| handler = handler.real || handler; | ||
| var nodeId = ensureId(node, '_nid'); | ||
| types.forEach(function(type){ | ||
| type = fixEventName(node, type); | ||
| removeEvent(node, type, handler); | ||
| var cacheKey = nodeId + '-' + type; | ||
| var real = handler._events[cacheKey] || handler; | ||
| removeEvent(node, type, real); | ||
| }) | ||
@@ -394,4 +414,1 @@ } | ||
| } | ||
@@ -399,3 +399,3 @@ var _ = require("../util"); | ||
| set = set.replace(_.setName, | ||
| prefix + setBuffer.join("") + "})("+ _.setName +")" ); | ||
| prefix + setBuffer.join("") + "})("+ _.setName +")" ); | ||
@@ -558,3 +558,3 @@ } | ||
| last = path; | ||
| base = ctxName + "._sg_('" + path + "', " + varName + ", " + extName + ")"; | ||
| base = ctxName + "._sg_('" + path + "', undefined, " + varName + ", " + extName + ")"; | ||
| onlySimpleAccessor = true; | ||
@@ -585,3 +585,3 @@ }else{ //Primative Type | ||
| if( this.la() !== "(" ){ | ||
| base = ctxName + "._sg_('" + tmpName + "', " + base + ")"; | ||
| base = ctxName + "._sg_('" + tmpName + "', " + base + " || null)"; | ||
| }else{ | ||
@@ -598,3 +598,3 @@ base += "." + tmpName ; | ||
| // and confirm that the function call wont lose its context | ||
| base = ctxName + "._sg_(" + path.get + ", " + base + ")"; | ||
| base = ctxName + "._sg_(" + path.get + ", " + base + " || null)"; | ||
| }else{ | ||
@@ -601,0 +601,0 @@ base += "[" + path.get + "]"; |
+24
-7
@@ -556,15 +556,32 @@ /** | ||
| // simple accessor get | ||
| _sg_:function(path, defaults, ext){ | ||
| // ext > parent > computed > defaults | ||
| _sg_:function(path, parent, defaults, ext){ | ||
| if( path === undefined ) return undefined; | ||
| if(ext && typeof ext === 'object'){ | ||
| if(ext[path] !== undefined) return ext[path]; | ||
| } | ||
| var computed = this.computed, | ||
| computedProperty = computed[path]; | ||
| if(computedProperty){ | ||
| if(computedProperty.type==='expression' && !computedProperty.get) this._touchExpr(computedProperty); | ||
| if(computedProperty.get) return computedProperty.get(this); | ||
| else _.log("the computed '" + path + "' don't define the get function, get data."+path + " altnately", "warn") | ||
| // reject to get from computed, return undefined directly | ||
| // like { empty.prop }, empty equals undefined | ||
| // prop shouldn't get from computed | ||
| if(parent === null) { | ||
| return undefined | ||
| } | ||
| if(parent && typeof parent[path] !== 'undefined') { | ||
| return parent[path] | ||
| } | ||
| // without parent, get from computed | ||
| if (parent !== null) { | ||
| var computed = this.computed, | ||
| computedProperty = computed[path]; | ||
| if(computedProperty){ | ||
| if(computedProperty.type==='expression' && !computedProperty.get) this._touchExpr(computedProperty); | ||
| if(computedProperty.get) return computedProperty.get(this); | ||
| else _.log("the computed '" + path + "' don't define the get function, get data."+path + " altnately", "warn") | ||
| } | ||
| } | ||
| if( defaults === undefined ){ | ||
@@ -571,0 +588,0 @@ return undefined; |
+5
-8
@@ -394,8 +394,12 @@ require('./helper/shim')(); | ||
| return function fire(obj){ | ||
| var sender = this; | ||
| self.$update(function(){ | ||
| var data = this.data; | ||
| data.$event = obj; | ||
| data.$sender = sender; | ||
| var res = evaluate(self); | ||
| if(res === false && obj && obj.preventDefault) obj.preventDefault(); | ||
| data.$event = undefined; | ||
| data.$sender = undefined; | ||
| }) | ||
@@ -570,3 +574,3 @@ | ||
| } | ||
| _.eventReg = /^on-(\w[-\w]+)$/; | ||
| _.eventReg = /^on-(\w[-\w]*)$/; | ||
@@ -619,8 +623,1 @@ _.toText = function(obj){ | ||
| } | ||
+1
-1
| { | ||
| "name": "regularjs", | ||
| "version": "0.6.0", | ||
| "version": "0.6.1", | ||
| "author": { | ||
@@ -5,0 +5,0 @@ "name": "leeluolee" |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
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
434181
0.57%11912
0.51%70
-5.41%1
Infinity%