From eb78488fee534e037f793ca571fc7053b95b8521 Mon Sep 17 00:00:00 2001 From: Mike Marcacci Date: Wed, 12 Nov 2014 22:30:15 -0800 Subject: [PATCH] Use objectpath more genericallyto fix requirejs issues --- bower.json | 2 +- src/module.js | 2 +- src/sfPath.js | 22 ++++++++++++---------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/bower.json b/bower.json index a41d4b662..c6f31ac1f 100644 --- a/bower.json +++ b/bower.json @@ -32,7 +32,7 @@ "angular": ">= 1.2", "tv4": "~1.0.15", "angular-sanitize": ">= 1.2", - "objectpath": "~1.0.4" + "objectpath": "~1.1.0" }, "devDependencies": { "angular-ui-ace": "bower", diff --git a/src/module.js b/src/module.js index d4133b5e2..2e0136e55 100644 --- a/src/module.js +++ b/src/module.js @@ -1,7 +1,7 @@ // Deps is sort of a problem for us, maybe in the future we will ask the user to depend // on modules for add-ons -var deps = ['ObjectPath']; +var deps = []; try { //This throws an expection if module does not exist. angular.module('ngSanitize'); diff --git a/src/sfPath.js b/src/sfPath.js index 11b69f1b6..56955a000 100644 --- a/src/sfPath.js +++ b/src/sfPath.js @@ -1,26 +1,28 @@ angular.module('schemaForm').provider('sfPath', -['ObjectPathProvider', function(ObjectPathProvider) { - var ObjectPath = {parse: ObjectPathProvider.parse}; +[function() { + var sfPath = {parse: ObjectPath.parse}; // if we're on Angular 1.2.x, we need to continue using dot notation if (angular.version.major === 1 && angular.version.minor < 3) { - ObjectPath.stringify = function(arr) { + sfPath.stringify = function(arr) { return Array.isArray(arr) ? arr.join('.') : arr.toString(); }; } else { - ObjectPath.stringify = ObjectPathProvider.stringify; + sfPath.stringify = ObjectPath.stringify; } // We want this to use whichever stringify method is defined above, // so we have to copy the code here. - ObjectPath.normalize = function(data, quote) { - return ObjectPath.stringify(Array.isArray(data) ? data : ObjectPath.parse(data), quote); + sfPath.normalize = function(data, quote) { + return sfPath.stringify(Array.isArray(data) ? data : sfPath.parse(data), quote); }; - this.parse = ObjectPath.parse; - this.stringify = ObjectPath.stringify; - this.normalize = ObjectPath.normalize; + // expose the methods in sfPathProvider + this.parse = sfPath.parse; + this.stringify = sfPath.stringify; + this.normalize = sfPath.normalize; + this.$get = function() { - return ObjectPath; + return sfPath; }; }]);