Scott,
is this what you were suggesting, to lighten JavaScriptObject.toString() for
micro-apps?
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---
Index: user/src/com/google/gwt/core/client/JavaScriptObject.java
===================================================================
--- user/src/com/google/gwt/core/client/JavaScriptObject.java (revision 5183)
+++ user/src/com/google/gwt/core/client/JavaScriptObject.java (working copy)
@@ -103,40 +103,47 @@
* Basic assumption here is that this code is for debugging only!
*/
@Override
- public final native String toString() /*-{
- var defined = function(m) { return typeof m != 'undefined'; };
- var strip = function(s) { return s.replace(/\r\n/g, ""); };
- // Output nodes that have outerHTML
- if (defined(this.outerHTML))
- return strip(this.outerHTML);
- // Output nodes that have innerHTML
- if (defined(this.innerHTML) && this.cloneNode) {
- $doc.createElement('div').appendChild(this.cloneNode(true)).innerHTML;
- }
- // Output text nodes
- if (defined(this.nodeType) && this.nodeType == 3) {
- return "'" +
- this.data.replace(/ /g, "\u25ab").replace(/\u00A0/, "\u25aa") +
- "'";
- }
- // Output IE's TextRange (this code specific to IE7)
- if (typeof defined(this.htmlText) && this.collapse) {
- var html = this.htmlText;
- if (html) {
- return 'IETextRange [' + strip(html) + ']';
- } else {
- // NOTE(lars): using pasteHTML to place a | where the range is collapsed
- // if *very* useful when debugging. It also, however, in certain very subtle
- // circumstances change the range being toStringed! If you see different
- // behaviour in debug vs. release builds (or if logging ranges changes the
- // behaviour, comment out the 4 of the 6 lines below containing dup.
- var dup = this.duplicate();
- dup.pasteHTML('|');
- var out = 'IETextRange ' + strip(this.parentElement().outerHTML);
- dup.moveStart('character', -1);
- dup.pasteHTML('');
- return out;
+ public final String toString() {
+ return toStringImpl(JavaScriptObject.class.desiredAssertionStatus());
+ }
+
+ public final native String toStringImpl(boolean verbose) /*-{
+ if (verbose) {
+ var defined = function(m) { return typeof m != 'undefined'; };
+ var strip = function(s) { return s.replace(/\r\n/g, ""); };
+ // Output nodes that have outerHTML
+ if (defined(this.outerHTML))
+ return strip(this.outerHTML);
+ // Output nodes that have innerHTML
+ if (defined(this.innerHTML) && this.cloneNode) {
+ $doc.createElement('div').appendChild(this.cloneNode(true)).innerHTML;
}
+ // Output text nodes
+ if (defined(this.nodeType) && this.nodeType == 3) {
+ return "'" +
+ this.data.replace(/ /g, "\u25ab").replace(/\u00A0/, "\u25aa") +
+ "'";
+ }
+ // Output IE's TextRange (this code specific to IE7)
+ if (typeof defined(this.htmlText) && this.collapse) {
+ var html = this.htmlText;
+ if (html) {
+ return 'IETextRange [' + strip(html) + ']';
+ } else {
+ // NOTE: using pasteHTML to place a | where the range is collapsed
+ // if *very* useful when debugging. It also, however, in certain very
+ // subtle circumstances change the range being toStringed! If you
+ // see different behaviour in debug vs. release builds (or if logging
+ // ranges changes the behaviour, comment out the 4 of the 6 lines
+ // below containing dup.
+ var dup = this.duplicate();
+ dup.pasteHTML('|');
+ var out = 'IETextRange ' + strip(this.parentElement().outerHTML);
+ dup.moveStart('character', -1);
+ dup.pasteHTML('');
+ return out;
+ }
+ }
}
return this.toString ? this.toString() : '[JavaScriptObject]';
}-*/;