mediawiki-extensions-Visual.../modules/ve/test
Timo Tijhof c8ed44fb07 Refactor ve.getHash: Stabilize cross-browser differences; + unit tests
* Replaces c8b4a28936

* Use Object() casting to detect objects instead of .constructor
  (or instanceof). Both .constructor and instanceof compare by reference
  the type "Object" which means if the object comes from another window
  (where there is a different "Object" and "Object.prototype") it will
  drop out of the system and go freewack.

  Theory: If a variable casted to an object returns true when strictly compared
  to the original, the input must be an object.

  Which is true. It doesn't change the inheritance, it doesn't make it inherit
  from this window's Object if the object is from another window's object. All it
  does is cast to an object if not an object already.
  So e.g. "Object(5) !== 5" because 5 is a primitive value as opposed to an instance
  of Number.
  And contrary to "typeof", it doesn't return true for "null".

* .constructor also has the problem that it only works this way if the
  input is a plain object. e.g. a simple construtor function that creates
  an object also get in the wrong side of the if/else case since it is
  an instance of Object, but not directly (rather indirectly via another
  constructor).

* Added unit tests for basic getHash usage, as well as regression tests
  against the above two mentioned problems (these tests fail before this commit).

* While at it, also improved other utilities a bit.
 - Use hasOwnProperty instead of casting to boolean
   when checking for presence of native support.
   Thanks to Douglas Crockford for that tip.
 - Fix documentation for ve.getHash: Parameter is not named "obj".
 - Add Object-check to ve.getObjectKeys per ES5 Object.keys spec (to match native behavior)
 - Add Object-check to ve.getObjectValues to match ve.getObjectKeys
 - Improved performance of ve.getObjectKeys shim. Tried several potential optimizations
   and compared with jsperf. Using a "static" reference to hasOwn improves performance
   (by not having to look it up 4 scopes up and 3 property levels deep).
   Also using [.length] instead of .push() shared off a few ms.
 - Added unit tests for ve.getObjectValues

Change-Id: If24d09405321f201c67f7df75d332bb1171c8a36
2012-08-27 00:14:02 +02:00
..
ce After much research on error objects, native = good, custom = bad 2012-08-08 10:48:53 -07:00
dm Preserve whitespace between elements 2012-08-23 19:08:00 -07:00
image.png Losslessly compress png images 2012-08-18 23:12:44 +01:00
index.html Refactor ve.getHash: Stabilize cross-browser differences; + unit tests 2012-08-27 00:14:02 +02:00
ve.BranchNode.test.js After much research on error objects, native = good, custom = bad 2012-08-08 10:48:53 -07:00
ve.Document.test.js
ve.example.js Puttin' em white-spacers where they aught'a be 2012-08-06 18:52:19 -07:00
ve.Factory.test.js Rename fringeWhitespace to internal 2012-08-16 15:14:01 -07:00
ve.LeafNode.test.js Refactor ve.js utilities and improve documentation 2012-08-12 20:32:45 +02:00
ve.Node.test.js
ve.qunit.js Rename fringeWhitespace to internal 2012-08-16 15:14:01 -07:00
ve.test.js Refactor ve.getHash: Stabilize cross-browser differences; + unit tests 2012-08-27 00:14:02 +02:00