Permalink
Browse files

try/catch JSON parse of window.top.name

  • Loading branch information...
1 parent 4aa8851 commit b89c3b661782ba510526632234cc5256087f1e9c @elsigh elsigh committed Jul 19, 2012
Showing with 9 additions and 2 deletions.
  1. +9 −2 src/adapters/window-name.js
@@ -4,8 +4,15 @@ Lawnchair.adapter('window-name', (function(index, store) {
window = { top: { } }; // node/optimizer compatibility
}
- var data = window.top.name ? JSON.parse(window.top.name) : {}
-
+ // edited from the original here by elsigh
+ // Some sites store JSON data in window.top.name, but some folks (twitter on iPad)
+ // put simple strings in there - we should make sure not to cause a SyntaxError.
+ var data = {}
+ try {
+ data = JSON.parse(window.top.name)
+ } catch (e) {}
+
+
return {
valid: function () {

0 comments on commit b89c3b6

Please sign in to comment.