You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by ev...@apache.org on 2008/10/09 21:58:42 UTC
svn commit: r703240 - in
/incubator/shindig/trunk/features/opensocial-templates: compiler.js
container.js namespaces.js
Author: evan
Date: Thu Oct 9 12:58:42 2008
New Revision: 703240
URL: http://svn.apache.org/viewvc?rev=703240&view=rev
Log:
Patch for SHINDIG-649: Fix some whitespace issues on IE, use gadgets.util.registerOnLoadHandler when available
Modified:
incubator/shindig/trunk/features/opensocial-templates/compiler.js
incubator/shindig/trunk/features/opensocial-templates/container.js
incubator/shindig/trunk/features/opensocial-templates/namespaces.js
Modified: incubator/shindig/trunk/features/opensocial-templates/compiler.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-templates/compiler.js?rev=703240&r1=703239&r2=703240&view=diff
==============================================================================
--- incubator/shindig/trunk/features/opensocial-templates/compiler.js (original)
+++ incubator/shindig/trunk/features/opensocial-templates/compiler.js Thu Oct 9 12:58:42 2008
@@ -50,7 +50,8 @@
if (child.nodeType == DOM_ELEMENT_NODE) {
nodes.push(os.compileNode_(child));
} else if (child.nodeType == DOM_TEXT_NODE) {
- if (!child.nodeValue.match(os.regExps_.onlyWhitespace)) {
+ if (child != node.firstChild ||
+ !child.nodeValue.match(os.regExps_.onlyWhitespace)) {
var compiled = os.breakTextNode_(child);
for (var i = 0; i < compiled.length; i++) {
nodes.push(compiled[i]);
@@ -453,12 +454,12 @@
var compiledChild = os.compileNode_(child);
if (compiledChild) {
if (!compiledChild.tagName &&
- typeof(compiledChild.length) == 'number') {
+ typeof(compiledChild.length) == 'number') {
for (var i = 0; i < compiledChild.length; i++) {
output.appendChild(compiledChild[i]);
}
} else {
- // If inserting a TRw into a TABLE, inject a TBODY element.
+ // If inserting a TR into a TABLE, inject a TBODY element.
if (compiledChild.tagName == 'TR' && output.tagName == 'TABLE') {
var lastEl = output.lastChild;
while (lastEl && lastEl.nodeType != DOM_ELEMENT_NODE &&
@@ -497,7 +498,7 @@
*/
os.prepareTemplateXML_ = function(templateSrc) {
var namespaces = os.getRequiredNamespaces(templateSrc);
- return "<!DOCTYPE root [" + os.ENTITIES + "]><root " +
+ return "<!DOCTYPE root [" + os.ENTITIES + "]><root xml:space=\"preserve\"" +
namespaces + ">" + templateSrc + "</root>";;
};
Modified: incubator/shindig/trunk/features/opensocial-templates/container.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-templates/container.js?rev=703240&r1=703239&r2=703240&view=diff
==============================================================================
--- incubator/shindig/trunk/features/opensocial-templates/container.js (original)
+++ incubator/shindig/trunk/features/opensocial-templates/container.js Thu Oct 9 12:58:42 2008
@@ -67,7 +67,10 @@
* @private
*/
os.Container.registerDomLoadListener_ = function() {
- if (navigator.product == 'Gecko') {
+ var gadgets = window['gadgets'];
+ if (gadgets && gadgets.util) {
+ gadgets.util.registerOnLoadHandler(os.Container.onDomLoad_);
+ } else if (navigator.product == 'Gecko') {
window.addEventListener("DOMContentLoaded", os.Container.onDomLoad_, false);
} if (window.addEventListener) {
window.addEventListener("load", os.Container.onDomLoad_, false);
Modified: incubator/shindig/trunk/features/opensocial-templates/namespaces.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-templates/namespaces.js?rev=703240&r1=703239&r2=703240&view=diff
==============================================================================
--- incubator/shindig/trunk/features/opensocial-templates/namespaces.js (original)
+++ incubator/shindig/trunk/features/opensocial-templates/namespaces.js Thu Oct 9 12:58:42 2008
@@ -155,6 +155,21 @@
}
result = resultArray;
}
+
+ // Trim away leading and trailing spaces on IE, which interprets them
+ // literally.
+ if (os.isIe) {
+ for (var i = 0; i < result.length; i++) {
+ if (result[i].nodeType == DOM_TEXT_NODE) {
+ var trimmed = os.trimWhitespaceForIE_(
+ result[i].nodeValue, (i == 0), (i == result.length - 1));
+ if (trimmed != result[i].nodeValue) {
+ result[i].parentNode.removeChild(result[i]);
+ result[i] = document.createTextNode(trimmed);
+ }
+ }
+ }
+ }
return result;
}