mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #343 from benjamn/fix-if-statement-pruning
Make constant propagation smarter about pruning if statements
This commit is contained in:
+1
-1
@@ -50,7 +50,7 @@
|
||||
"grunt-contrib-jshint": "~0.6.0",
|
||||
"optimist": "~0.6.0",
|
||||
"phantomjs": "~1.9.1-4",
|
||||
"recast": "~0.4.8",
|
||||
"recast": "~0.4.16",
|
||||
"semver": "~2.1.0",
|
||||
"uglify-js": "~2.4.0",
|
||||
"grunt-contrib-clean": "~0.5.0",
|
||||
|
||||
@@ -87,12 +87,10 @@ var DOMPropertyOperations = {
|
||||
}
|
||||
return processAttributeNameAndPrefix(name) +
|
||||
escapeTextForBrowser(value) + '"';
|
||||
} else {
|
||||
if (__DEV__) {
|
||||
warnUnknownProperty(name);
|
||||
}
|
||||
return null;
|
||||
} else if (__DEV__) {
|
||||
warnUnknownProperty(name);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -121,10 +119,8 @@ var DOMPropertyOperations = {
|
||||
}
|
||||
} else if (DOMProperty.isCustomAttribute(name)) {
|
||||
node.setAttribute(name, value);
|
||||
} else {
|
||||
if (__DEV__) {
|
||||
warnUnknownProperty(name);
|
||||
}
|
||||
} else if (__DEV__) {
|
||||
warnUnknownProperty(name);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -150,10 +146,8 @@ var DOMPropertyOperations = {
|
||||
}
|
||||
} else if (DOMProperty.isCustomAttribute(name)) {
|
||||
node.removeAttribute(name);
|
||||
} else {
|
||||
if (__DEV__) {
|
||||
warnUnknownProperty(name);
|
||||
}
|
||||
} else if (__DEV__) {
|
||||
warnUnknownProperty(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+7
-1
@@ -53,7 +53,13 @@ var ConstantVisitor = recast.Visitor.extend({
|
||||
} else if (stmt.alternate) {
|
||||
return stmt.alternate;
|
||||
} else {
|
||||
this.remove();
|
||||
// In case this if statement is an alternate clause for another
|
||||
// if-statement, replacing that alternate with null will have the
|
||||
// effect of pruning the unnecessary clause. If this is just a
|
||||
// free-floating if statement, replacing it with null will have
|
||||
// the effect of removing it from the enclosing list of
|
||||
// statements.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user