Skip to content
This repository has been archived by the owner on Sep 20, 2020. It is now read-only.

Commit

Permalink
fix($stickyState): Made equalForKeys compatible with state.ownParams …
Browse files Browse the repository at this point in the history
…breaking change in UI-Router 0.2.11+

`ownParams` used to be an array, but was changed to an object, then to a ParamSet.  To make ui-router-extras with all 3, check if `keys` is an object and then grab the object's protoKeys

Closes #112
  • Loading branch information
christopherthielen committed Dec 4, 2014
1 parent 31ca73b commit 5aba134
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ui-router-extras",
"version": "0.0.11",
"version": "0.0.12-pre1",
"authors": [
"Chris Thielen <[email protected]>"
],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "Christopher Thielen",
"name": "ui-router-extras",
"version": "0.0.11",
"version": "0.0.12-pre1",
"description": "UI-Router Extras: Sticky states, Future States, Deep State Redirect, Transition promise",
"homepage": "http://christopherthielen.github.io/ui-router-extras/",
"dependencies": {},
Expand Down
3 changes: 3 additions & 0 deletions src/stickyStateProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ function $StickyStateProvider($stateProvider) {

// Duplicates logic in $state.transitionTo, primarily to find the pivot state (i.e., the "keep" value)
function equalForKeys(a, b, keys) {
if (angular.isObject(keys)) {
keys = protoKeys(keys, ["$$keys", "$$values", "$$equals", "$$validates"]);
}
if (!keys) {
keys = [];
for (var n in a) keys.push(n); // Used instead of Object.keys() for IE8 compatibility
Expand Down
15 changes: 15 additions & 0 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ function objectKeys(object) {
return result;
}

/**
* like objectKeys, but includes keys from prototype chain.
* @param object the object whose prototypal keys will be returned
* @param ignoreKeys an array of keys to ignore
*/
// Duplicates code in UI-Router common.js
function protoKeys(object, ignoreKeys) {
var result = [];
for (var key in object) {
if (!ignoreKeys || ignoreKeys.indexOf(key) === -1)
result.push(key);
}
return result;
}

// Duplicates code in UI-Router common.js
function arraySearch(array, value) {
if (Array.prototype.indexOf) {
Expand Down

0 comments on commit 5aba134

Please sign in to comment.