Permalink
Browse files

use less strict assert tests in the debug version: sometimes we get n…

…odes like comment or text, and not elements
  • Loading branch information...
1 parent 1894a5d commit 455e82bda90b7ccd9f0bf609cd1a6f527b991616 @julienw committed Aug 15, 2012
Showing with 18 additions and 9 deletions.
  1. +8 −4 dollardom-full.debug.js
  2. +2 −1 examples/index.html
  3. +8 −4 src/dollardom.js
@@ -159,6 +159,10 @@
assert(msg + " is element", elm instanceof window.Element);
}
+ function assertNode(msg, elm) {
+ assert(msg + " is a node", elm instanceof window.Node);
+ }
+
function assertString(msg, str) {
var type = typeof str;
assert(msg + " is string", type === "string");
@@ -398,7 +402,7 @@
function _find(elm, property, selectorFragment) {
/*!debug*/
- assertElement("elm", elm);
+ assertNode("elm", elm);
if (selectorFragment !== _undefined) {
assertSimpleSelector("selectorFragment", selectorFragment);
}
@@ -419,7 +423,7 @@
function _findNext(elm, property, selector) {
/*!debug*/
- assertElement("elm", elm);
+ assertNode("elm", elm);
if (selector !== _undefined) {
assertSimpleSelector("selector", selector);
}
@@ -542,7 +546,7 @@
function _first(elm, selector) {
/*!debug*/
- assertElement("elm", elm);
+ assertNode("elm", elm);
if (selector !== _undefined) {
assertSimpleSelector("selector", selector);
}
@@ -553,7 +557,7 @@
}
function _last(elm, selector) {
/*!debug*/
- assertElement("elm", elm);
+ assertNode("elm", elm);
if (selector !== _undefined) {
assertSimpleSelector("selector", selector);
}
View
@@ -27,7 +27,8 @@
</div>
- <script src='../dollardom-animate.min.js'></script>
+ <script src='../src/dollardom.js'></script>
+ <script src='../src/animate.js'></script>
<script src='sh_main.min.js'></script>
<script src='sh_javascript_dom.min.js'></script>
<script src='examples.js'></script>
View
@@ -159,6 +159,10 @@
assert(msg + " is element", elm instanceof window.Element);
}
+ function assertNode(msg, elm) {
+ assert(msg + " is a node", elm instanceof window.Node);
+ }
+
function assertString(msg, str) {
var type = typeof str;
assert(msg + " is string", type === "string");
@@ -398,7 +402,7 @@
function _find(elm, property, selectorFragment) {
/*!debug*/
- assertElement("elm", elm);
+ assertNode("elm", elm);
if (selectorFragment !== _undefined) {
assertSimpleSelector("selectorFragment", selectorFragment);
}
@@ -419,7 +423,7 @@
function _findNext(elm, property, selector) {
/*!debug*/
- assertElement("elm", elm);
+ assertNode("elm", elm);
if (selector !== _undefined) {
assertSimpleSelector("selector", selector);
}
@@ -542,7 +546,7 @@
function _first(elm, selector) {
/*!debug*/
- assertElement("elm", elm);
+ assertNode("elm", elm);
if (selector !== _undefined) {
assertSimpleSelector("selector", selector);
}
@@ -553,7 +557,7 @@
}
function _last(elm, selector) {
/*!debug*/
- assertElement("elm", elm);
+ assertNode("elm", elm);
if (selector !== _undefined) {
assertSimpleSelector("selector", selector);
}

0 comments on commit 455e82b

Please sign in to comment.