Permalink
Browse files

Merge master

  • Loading branch information...
2 parents d2ab752 + a75d3bf commit ce34678cfbd150894ae175763e0e4184de28f488 @briancavalier briancavalier committed Jun 6, 2013
Showing with 38 additions and 17 deletions.
  1. +8 −0 CHANGES.md
  2. +8 −0 README.md
  3. +21 −16 dom/render.js
  4. +1 −1 wire.js
View
@@ -1,3 +1,11 @@
+### 0.9.4
+
+* Fix for [render factory](docs/dom.md#rendering-dom-elements) in IE8.
+
+### 0.9.3
+
+* Compatibility with when.js 1.5.0 - 2.0.x. If you use when >= 2.0.0, you *MUST* update to wire 0.9.3. There are no other changes in 0.9.3.
+
### 0.9.2
* IE-specific fix for `wire/debug`'s `trace` option. See [#78](https://github.com/cujojs/wire/issues/78)
View
@@ -14,6 +14,14 @@ To find out more, read the [full introduction](docs/introduction.md), more about
# What's new
+### 0.9.4
+
+* Fix for [render factory](docs/dom.md#rendering-dom-elements) in IE8.
+
+### 0.9.3
+
+* Compatibility with when.js 1.5.0 - 2.0.x. If you use when >= 2.0.0, you *MUST* update to wire 0.9.3. There are no other changes in 0.9.3.
+
### 0.9.2
* IE-specific fix for `wire/debug`'s `trace` option. See [#78](https://github.com/cujojs/wire/issues/78)
View
@@ -104,33 +104,38 @@ define(['./../lib/dom/base', 'when'], function (base, when) {
* @returns {HTMLElement} the element created from the template
*/
function createElementFromTemplate (template) {
- var parentTagName, parent, first, child;
+ var parentTagName, parent, first, tooMany, node;
parentTagName = getParentTagName(template);
parent = document.createElement(parentTagName);
parent.innerHTML = template;
// we just want to return first element (nodelists and fragments
- // are tricky), so we loop through all top-level children to ensure
- // we only have one.
+ // are tricky), so we ensure we only have one.
+ // TODO: try using DocumentFragments to allow multiple root elements
// try html5-ish API
- first = parent.firstElementChild;
- child = parent.lastElementChild;
-
- // old dom API
- if (!first) {
- child = parent.firstChild;
- while (child) {
- if (child.nodeType == 1 && !first) {
- first = child;
+ if ('firstElementChild' in parent) {
+ first = parent.firstElementChild;
+ tooMany = first != parent.lastElementChild;
+ }
+ else {
+ // loop through nodes looking for elements
+ node = parent.firstChild;
+ while (node && !tooMany) {
+ if (node.nodeType == 1 /* 1 == element */) {
+ if (!first) first = node;
+ else tooMany = true;
}
- child = child.nextSibling;
+ node = node.nextSibling;
}
}
- if (first != child) {
- throw new Error('render: only one element per template is supported.');
+ if (!first) {
+ throw new Error('render: no element found in template.');
+ }
+ else if (tooMany) {
+ throw new Error('render: only one root element per template is supported.');
}
return first;
@@ -197,7 +202,7 @@ define(['./../lib/dom/base', 'when'], function (base, when) {
if (!hashmap) {
return template;
}
-
+
if (!missing) {
missing = blankIfMissing;
}
View
@@ -11,7 +11,7 @@
* Licensed under the MIT License at:
* http://www.opensource.org/licenses/mit-license.php
*
- * @version 0.9.2
+ * @version 0.10.0
*/
(function(rootSpec, define){ 'use strict';
define(function(require) {

0 comments on commit ce34678

Please sign in to comment.