Permalink
Browse files

Merge pull request #2210 from twoRoger/fix-constructor

Fix bug when using 'constructor' in variables or loops
  • Loading branch information...
2 parents 9ca2774 + 04f1bbc commit 9fa99d1ed8346414d8cf9e8b4b5638459cfbc9de @Panya Panya committed on GitHub Jul 18, 2016
Showing with 25 additions and 1 deletion.
  1. +10 −1 lib/stack/scope.js
  2. +8 −0 test/cases/object-prototype-props.css
  3. +7 −0 test/cases/object-prototype-props.styl
View
@@ -35,7 +35,7 @@ Scope.prototype.add = function(ident){
*/
Scope.prototype.lookup = function(name){
- return this.locals[name];
+ return hasOwnProperty(this.locals, name) ? this.locals[name] : undefined;
};
/**
@@ -51,3 +51,12 @@ Scope.prototype.inspect = function(){
+ (keys.length ? ' ' + keys.join(', ') : '')
+ ']';
};
+
+/**
+ * @param {Object} obj
+ * @param {String} propName
+ * @returns {Boolean}
+ */
+function hasOwnProperty(obj, propName) {
+ return Object.prototype.hasOwnProperty.call(obj, propName);
+}
@@ -0,0 +1,8 @@
+body {
+ foo: constructor;
+}
+body {
+ foo: foo;
+ foo: constructor;
+ foo: hasOwnProperty;
+}
@@ -0,0 +1,7 @@
+val = constructor
+body
+ foo val
+
+body
+ for val in foo constructor hasOwnProperty
+ foo val

0 comments on commit 9fa99d1

Please sign in to comment.