diff --git a/meta/safariextz/Info.plist b/meta/safariextz/Info.plist
index 489b0599f..48d45c364 100644
--- a/meta/safariextz/Info.plist
+++ b/meta/safariextz/Info.plist
@@ -27,8 +27,12 @@
Filename
popup.html
+ Height
+ 1
Identifier
popover
+ Width
+ 1
Toolbar Items
diff --git a/src/Info.plist b/src/Info.plist
index 669678d8f..dfce939ac 100644
--- a/src/Info.plist
+++ b/src/Info.plist
@@ -27,8 +27,12 @@
Filename
popup.html
+ Height
+ 1
Identifier
popover
+ Width
+ 1
Toolbar Items
diff --git a/src/js/vapi-common.js b/src/js/vapi-common.js
index d70c4497a..e2153d59b 100644
--- a/src/js/vapi-common.js
+++ b/src/js/vapi-common.js
@@ -49,12 +49,35 @@ if (window.chrome) {
// update popover size to its content
if (safari.self.identifier === 'popover' && safari.self) {
- vAPI.updatePopoverSize = function() {
- safari.self.width = document.body.clientWidth;
- safari.self.height = document.body.clientHeight;
- };
+ (function() {
+ var upadteTimer = null;
+ var resizePopover = function() {
+ if (upadteTimer) {
+ return;
+ }
- setTimeout(vAPI.updatePopoverSize, 200);
+ upadteTimer = setTimeout(function() {
+ safari.self.width = document.body.clientWidth;
+ safari.self.height = document.body.clientHeight;
+ upadteTimer = null;
+ }, 50);
+ };
+
+ var mutObs = window.MutationObserver || window.WebkitMutationObserver;
+
+ if (mutObs) {
+ (new mutObs(resizePopover)).observe(document, {
+ childList: true,
+ attributes: true,
+ characterData: true,
+ subtree: true
+ });
+ }
+ else {
+ // Safari doesn't support DOMAttrModified
+ document.addEventListener('DOMSubtreeModified', resizePopover);
+ }
+ })();
}
}