Permalink
Browse files

- added a couple more tests for `Object.prototype.__proto__` — only r…

…eally needed for testing MSIE, since it doesn't support the `__proto__` prop

- fixed failing MSIE `m8.ptype` tests
- added some more documentation for actual return results of `m8.ptype` under MSIE
  • Loading branch information...
1 parent dc51558 commit 491f4bfa0a561d76c0b72d4dc03cefd74ef5ab43 @constantology committed Dec 21, 2012
Showing with 26 additions and 6 deletions.
  1. +15 −5 README.md
  2. +11 −1 test/m8.test.js
View
@@ -657,15 +657,25 @@ Returns the native `type` of the passed item's `__proto__`.
m8.ptype( '' ); // returns => "string"
- m8.ptype( document.createElement( 'div' ) ); // returns => "object" | "xpc_..._jsclass" <- FireFox :P
+ m8.ptype( document.createElement( 'div' ) ); // returns => "object" <- WebKit
+ // | "xpc_..._jsclass" <- FireFox
+ // | "htmldivelementprototype" <- MSIE >= 9
- m8.ptype( document.querySelectorAll( 'div' ) ); // returns => "object" | "xpc_..._jsclass"
+ m8.ptype( document.querySelectorAll( 'div' ) ); // returns => "object" <- WebKit
+ // | "xpc_..._jsclass" <- FireFox
+ // | "htmlcollectionprototype" <- MSIE >= 9
- m8.ptype( document.getElementsByTagName( 'div' ) ); // returns => "object" | "xpc_..._jsclass"
+ m8.ptype( document.getElementsByTagName( 'div' ) ); // returns => "object" <- WebKit
+ // | "xpc_..._jsclass" <- FireFox
+ // | "nodelistprototype" <- MSIE >= 9
- m8.ptype( global ); // returns => "object" | "xpc_..._jsclass"
+ m8.ptype( global ); // returns => "object" <- WebKit
+ // | "xpc_..._jsclass" <- FireFox
+ // | "windowprototype" <- MSIE >= 9
- m8.ptype( window ); // returns => "object" | "xpc_..._jsclass"
+ m8.ptype( window ); // returns => "object" <- WebKit
+ // | "xpc_..._jsclass" <- FireFox
+ // | "windowprototype" <- MSIE >= 9 (I like the MSIE ones the best!)
```
View
@@ -334,7 +334,15 @@ suite( 'm8', function() {
}, 'cw', true );
var col = new Collection( 1, 2, 3, 4, 5 ),
- re_dom = /object|xpc_.*/;
+// for any Node `__proto__`:
+// - webkit returns `object` as the type
+// - firefox returns `xpc_..._jsclass` something or other
+// - msie >=9 returns `html*elementprototype` for HTMLElement;
+// `htmlcollectionprototype` for HTMLCollection (querySelectorAll);
+// `nodelistprototype` for NodeList (getElementsByTagName);
+// `windowprototype` for global/window
+// personally I like what MSIE returns the bestest! :D
+ re_dom = /object|xpc_.*|(html|node|window).*prototype/;
expect( m8.ntype( col ) ).to.equal( 'object' );
expect( m8.ptype( col ) ).to.equal( 'array' );
@@ -484,6 +492,8 @@ suite( 'm8', function() {
expect( m8.type( col.slice( 0 ) ) ).to.equal( 'collection' );
expect( col.slice( 1, 3 ).length ).to.equal( 2 );
expect( col.length ).to.equal( 5 );
+ expect( m8.type( col.__proto__ ) ).to.equal( 'collection' );
+ expect( m8.type( col.__proto__.__proto__ ) ).to.equal( 'array' );
done();
} );

0 comments on commit 491f4bf

Please sign in to comment.