goog.dom.query

169 views
Skip to first unread message

flpalm

unread,
Dec 4, 2013, 12:11:35 PM12/4/13
to closure-lib...@googlegroups.com
The goog.dom.query namespace exports itself(http://docs.closure-library.googlecode.com/git/closure_third_party_closure_goog_dojo_dom_query.js.source.html) at the very bottom of the code and there is a TODO to fix this, but it is still in there. Is it possible to get these lines removed or is there a reason that the library exports itself?

This causes issues when closure is used to create a library as these exports make their way into the end compiled code even when done in advanced mode with a wrapper. Then that namespace will clash with anyone using closure and referencing your library javascript since goog.require errors on duplicate namespace declarations in uncompiled mode.

Andy Martone

unread,
Dec 4, 2013, 1:20:51 PM12/4/13
to closure-lib...@googlegroups.com
Is there a reason you're still using goog.dom.query instead of the native querySelector/querySelectorAll API? (https://developer.mozilla.org/en-US/docs/Web/API/Document.querySelectorAll)


On Wed, Dec 4, 2013 at 9:11 AM, flpalm <nat...@gmail.com> wrote:
The goog.dom.query namespace exports itself(http://docs.closure-library.googlecode.com/git/closure_third_party_closure_goog_dojo_dom_query.js.source.html) at the very bottom of the code and there is a TODO to fix this, but it is still in there. Is it possible to get these lines removed or is there a reason that the library exports itself?

This causes issues when closure is used to create a library as these exports make their way into the end compiled code even when done in advanced mode with a wrapper. Then that namespace will clash with anyone using closure and referencing your library javascript since goog.require errors on duplicate namespace declarations in uncompiled mode.

--
 
---
You received this message because you are subscribed to the Google Groups "Closure Library Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to closure-library-d...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

张屾

unread,
Dec 7, 2013, 7:23:34 AM12/7/13
to closure-lib...@googlegroups.com
Hi flpalm, do you mean someone else uses uncompiled code along with the compiled code you provided?

flpalm

unread,
Dec 7, 2013, 12:41:27 PM12/7/13
to closure-lib...@googlegroups.com
Yes, so for example if I created a library somethingneat.js which is compiled and then you wanted to use my somethingneat.js library, but also use closure library for your website. During development of your website, goog.require would exception out if you use goog.dom.query as the compiled somethingneat.js has it exported. The goog.dom.query library exports its namespace which is then in the global namespace and conflicts with your development code on the same page.

The only reason I specify development is that goog.require doesn't generate an exception when you compile your javascript. It is only for development to help prevent duplicate namespace declarations.
Reply all
Reply to author
Forward
0 new messages