Closure Library is not optimized for Closure Compiler

10 views
Skip to first unread message

aachurin

unread,
Nov 28, 2010, 9:47:27 AM11/28/10
to Closure Library Discuss
I experimented with "Closure Library" and discovered that the library
is not optimized for "Closure Compiler".
What I mean?

--------------------------------------------------------
Simple example:
--------------------------------------------------------
test.Test = function(){
}

// removeChild is declared in ie_dom.js, w3c_dom.js and gecko_dom.js
(externs)
// and the same method name is used for goog.ui.Component,
goog.ui.Control and etc.
// see closure-compiler/externs/* to get full list of methods that
should not be used.
test.Test.prototype.removeChild = function() {
alert('Add child');
}

test.Test.prototype.simpleTest = function() {
this.removeChild();
}

var x = new test.Test();
x.simpleTest();

--------------------------------------------------------
After compilation:
--------------------------------------------------------
function a(){}a.prototype.removeChild=function(){alert("Add child")};
(new a).removeChild();

--------------------------------------------------------
Trying to rename removeChild:
--------------------------------------------------------

test.Test = function(){
}

test.Test.prototype.removeChildX = function() {
alert('Add child');
}

test.Test.prototype.simpleTest = function() {
this.removeChildX();
}

var x = new test.Test();
x.simpleTest();

--------------------------------------------------------
After compilation:
--------------------------------------------------------
alert("Add child");

Michael Davidson

unread,
Nov 29, 2010, 2:12:28 PM11/29/10
to closure-lib...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages