Created
May 30, 2012 02:52
-
-
Save ejholmes/2833347 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From e8ec3b84ab4eec55f2b1fe9a5cee294a5352ee78 Mon Sep 17 00:00:00 2001 | |
From: "Eric J. Holmes" <[email protected]> | |
Date: Tue, 29 May 2012 19:50:13 -0700 | |
Subject: [PATCH] Need to check if the object has it's own property, so that | |
libraries like emberjs don't cause issues by polluting | |
object prototypes. | |
--- | |
js/src/utils/jwplayer.utils.strings.js | 42 +++++++++++++++++--------------- | |
1 file changed, 22 insertions(+), 20 deletions(-) | |
diff --git a/js/src/utils/jwplayer.utils.strings.js b/js/src/utils/jwplayer.utils.strings.js | |
index 31f5f29..5bb7499 100644 | |
--- a/js/src/utils/jwplayer.utils.strings.js | |
+++ b/js/src/utils/jwplayer.utils.strings.js | |
@@ -122,27 +122,29 @@ | |
isArray = (obj && obj.constructor == Array); | |
for (var item in obj) { | |
- var value = obj[item]; | |
- | |
- switch (typeof(value)) { | |
- case "string": | |
- value = '"' + value.replace(/"/g, '\\"') + '"'; | |
- break; | |
- case "object": | |
- if (jwplayer.utils.exists(value)) { | |
- value = jwplayer.utils.strings.jsonToString(value); | |
- } | |
- break; | |
- } | |
- if (isArray) { | |
- // Array | |
- if (typeof(value) != "function") { | |
- toReturn.push(String(value)); | |
+ if (obj.hasOwnProperty(item)) { | |
+ var value = obj[item]; | |
+ | |
+ switch (typeof(value)) { | |
+ case "string": | |
+ value = '"' + value.replace(/"/g, '\\"') + '"'; | |
+ break; | |
+ case "object": | |
+ if (jwplayer.utils.exists(value)) { | |
+ value = jwplayer.utils.strings.jsonToString(value); | |
+ } | |
+ break; | |
} | |
- } else { | |
- // Object | |
- if (typeof(value) != "function") { | |
- toReturn.push('"' + item + '":' + String(value)); | |
+ if (isArray) { | |
+ // Array | |
+ if (typeof(value) != "function") { | |
+ toReturn.push(String(value)); | |
+ } | |
+ } else { | |
+ // Object | |
+ if (typeof(value) != "function") { | |
+ toReturn.push('"' + item + '":' + String(value)); | |
+ } | |
} | |
} | |
} | |
-- | |
1.7.9.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment