From 1ec5bb992963bf9dd394ba5064b07a8f10e3ea19 Mon Sep 17 00:00:00 2001 From: Artem Kholodenko Date: Sun, 27 Jan 2013 23:09:12 -0800 Subject: [PATCH] Implemented fix Added error handling to popover check. by chrismatthieu and fixed the resulting error Uncaught TypeError: Cannot call method 'contains' of undefined --- dist/ratchet.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dist/ratchet.js b/dist/ratchet.js index 4059da3..bbe8796 100644 --- a/dist/ratchet.js +++ b/dist/ratchet.js @@ -70,9 +70,16 @@ var anchor = findPopovers(e.target); if (!anchor || !anchor.hash) return; - - popover = document.querySelector(anchor.hash); - + + try{ + popover = document.querySelector(anchor.hash); + } + catch (error) { + popover = null; + } + + if (popover == null) return; + if (!popover || !popover.classList.contains('popover')) return; return popover;