Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Commit

Permalink
change Array.isArray backfill
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordon Koo committed Apr 5, 2013
1 parent d87ef47 commit 74bdfb8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 53 deletions.
30 changes: 11 additions & 19 deletions js/hopscotch-0.0.5.js
Expand Up @@ -40,6 +40,12 @@
return;
}

if (!Array.isArray) {
Array.isArray = function(obj) {
return Object.prototype.toString.call(obj) === '[object Array]';
};
}

/**
* Called when the page is done loading.
*
Expand Down Expand Up @@ -156,7 +162,7 @@
invokeCallbackArrayHelper: function(arr) {
// Logic for a single callback
var fn;
if (utils.isArray(arr)) {
if (Array.isArray(arr)) {
fn = helpers[arr[0]];
if (typeof fn === 'function') {
fn.apply(this, arr.slice(1));
Expand All @@ -175,7 +181,7 @@
invokeCallbackArray: function(arr) {
var i, len;

if (utils.isArray(arr)) {
if (Array.isArray(arr)) {
if (typeof arr[0] === 'string') {
// Assume there are no nested arrays. This is the one and only callback.
utils.invokeCallbackArrayHelper(arr);
Expand All @@ -197,10 +203,8 @@
if (typeof cb === 'function') {
cb();
}
if (typeof cb === 'string') { // name of a helper
if (helpers[cb]) {
helpers[cb]();
}
if (typeof cb === 'string' && helpers[cb]) { // name of a helper
helpers[cb]();
}
else { // assuming array
utils.invokeCallbackArray(cb);
Expand Down Expand Up @@ -339,13 +343,6 @@
return step.target;
},

/**
* @private
*/
isArray: Array.isArray || function(obj) {
return Object.prototype.toString.call(obj) === '[object Array]';
},

// Tour session persistence for multi-page tours. Uses HTML5 sessionStorage if available, then
// falls back to using cookies.
//
Expand Down Expand Up @@ -1069,7 +1066,7 @@
/**
* Append to body once the DOM is ready.
*/
if ( document.readyState === 'complete' ) {
if (document.readyState === 'complete') {
document.body.appendChild(el);
}
else {
Expand Down Expand Up @@ -1850,11 +1847,6 @@
return this;
};

/**
* Alias for unlisten
*/
this.removeCallback = this.unlisten;

/**
* removeCallbacks
*
Expand Down

0 comments on commit 74bdfb8

Please sign in to comment.