Permalink
Browse files

fix module browser in IE8

  • Loading branch information...
afri committed Sep 28, 2011
1 parent 486cb1f commit 4c44cbd819a0e68abfaa1de2bd182773221c51ec
Showing with 26 additions and 7 deletions.
  1. +1 −1 doc/module-browser.sjs
  2. +1 −0 doc/modules.html
  3. +24 −6 modules/ui.sjs
View
@@ -88,7 +88,7 @@ var getLibDocs = exports.getLibDocs = cutil.makeMemoizedFunction(function(libpat
});
var getModuleDocs = cutil.makeMemoizedFunction(function(modulepath) {
- try { console.log('getting '+modulepath);
+ try {
if (modulepath.charAt(modulepath.length-1) == '/') return null;
var docs = docutil.parseModuleDocs(http.get(modulepath + ".sjs"));
return docs;
View
@@ -1,3 +1,4 @@
+<!DOCTYPE HTML>
<html>
<head>
<link href="modules.css" rel="stylesheet" type="text/css" media="screen,projection" />
View
@@ -100,6 +100,27 @@ function ui_supplant(replacements) {
return this;
};
+/**
+ @function forEachContentNode
+*/
+function forEachContentNode(domparent, f) {
+ if (document.createNodeIterator) {
+ var iter = document.createNodeIterator(domparent,
+ NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,
+ null, false);
+ var node;
+ while ((node = iter.nextNode()))
+ f(node);
+ }
+ else {
+ // IE8 and below
+ f(domparent);
+ var children = domparent.childNodes;
+ for (var i=0; i<children.length; ++i)
+ forEachContentNode(children[i], f);
+ }
+}
+
/**
@function makeView
*/
@@ -122,11 +143,8 @@ var makeView = exports.makeView = function(html_template) {
// collect all templates (potentially slow)
var templates = [];
- var iter = document.createNodeIterator(holder,
- NodeFilter.SHOW_ELEMENT|
- NodeFilter.SHOW_TEXT, null, false);
- var node, matches;
- while ((node=iter.nextNode())) {
+ forEachContentNode(holder, function(node) {
+ var matches;
if (node.attributes) {
for (var i=0; i<node.attributes.length; ++i) {
if ((matches = node.attributes[i].value.match(/{[^\}]*}/g))) {
@@ -145,7 +163,7 @@ var makeView = exports.makeView = function(html_template) {
vars: coll.map(matches, stripFirstLast)
});
}
- }
+ });
return {
top : children,

0 comments on commit 4c44cbd

Please sign in to comment.