Skip to content

Commit

Permalink
Optimize goog.dom.TagName members instead of goog.dom.TypedTagName.
Browse files Browse the repository at this point in the history
We decided to add the type information directly to goog.dom.TagName and delete goog.dom.TypedTagName.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=127615565
  • Loading branch information
vrana authored and blickly committed Jul 18, 2016
1 parent 0ed4322 commit 67f331a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Expand Up @@ -59,7 +59,7 @@ public void visit(NodeTraversal t, Node n, Node parent) {
processObjectCreateSetCall(n);
}
}
maybeProcessDomTypedTagName(n);
maybeProcessDomTagName(n);
}
}

Expand Down Expand Up @@ -192,16 +192,16 @@ private static boolean canOptimizeObjectCreateSet(Node firstParam) {
/**
* Converts the given node to string if it is safe to do so.
*/
private void maybeProcessDomTypedTagName(Node n) {
private void maybeProcessDomTagName(Node n) {
String qualifiedName = n.getQualifiedName();
if (qualifiedName == null) {
return;
}
if (NodeUtil.isLValue(n)) {
return;
}
String prefix = "goog.dom.TypedTagName.";
String altPrefix = "goog$dom$TypedTagName$";
String prefix = "goog.dom.TagName.";
String altPrefix = "goog$dom$TagName$";
String tagName;
if (qualifiedName.startsWith(prefix)) {
tagName = qualifiedName.substring(prefix.length());
Expand Down
Expand Up @@ -78,10 +78,11 @@ public void testObjectCreateSet4() {
test("goog.object.createSet('a').toString()", "({'a':true}).toString()");
}

public void testDomTypedTagName() {
testSame("goog.dom.TypedTagName.A = 'A';");
test("goog.dom.createDom(goog.dom.TypedTagName.A)", "goog.dom.createDom('A')");
test("goog$dom$createDom(goog$dom$TypedTagName$A)", "goog$dom$createDom('A')");
test("goog.dom.createDom(goog.dom.TypedTagName.A + 'REA')", "goog.dom.createDom('A' + 'REA')");

public void testDomTagName() {
testSame("goog.dom.TagName.A = 'A';");
test("goog.dom.createDom(goog.dom.TagName.A)", "goog.dom.createDom('A')");
test("goog$dom$createDom(goog$dom$TagName$A)", "goog$dom$createDom('A')");
test("goog.dom.createDom(goog.dom.TagName.A + 'REA')", "goog.dom.createDom('A' + 'REA')");
}
}

0 comments on commit 67f331a

Please sign in to comment.