summaryrefslogtreecommitdiff
path: root/www/external/js/angular-ios9-uiwebview.patch.js
diff options
context:
space:
mode:
authorPliable Pixels <pliablepixels@gmail.com>2019-03-31 07:26:37 -0400
committerPliable Pixels <pliablepixels@gmail.com>2019-03-31 07:26:37 -0400
commit71114877e8e5409e37dc5a4c03015408f8e905fc (patch)
tree4d939c212d0fd21ba360012022e208be61f92e53 /www/external/js/angular-ios9-uiwebview.patch.js
parentf02d53b6318e2bf492a5b7d6c0c7b2f6de3bb8dd (diff)
#801 rip out bower, move to unmanaged externals
Diffstat (limited to 'www/external/js/angular-ios9-uiwebview.patch.js')
-rw-r--r--www/external/js/angular-ios9-uiwebview.patch.js73
1 files changed, 73 insertions, 0 deletions
diff --git a/www/external/js/angular-ios9-uiwebview.patch.js b/www/external/js/angular-ios9-uiwebview.patch.js
new file mode 100644
index 00000000..c52cad82
--- /dev/null
+++ b/www/external/js/angular-ios9-uiwebview.patch.js
@@ -0,0 +1,73 @@
+/**
+ * ================== angular-ios9-uiwebview.patch.js v1.1.0 ==================
+ *
+ * This patch works around iOS9 UIWebView regression that causes infinite digest
+ * errors in Angular.
+ *
+ * The patch can be applied to Angular 1.2.0 – 1.4.5. Newer versions of Angular
+ * have the workaround baked in.
+ *
+ * To apply this patch load/bundle this file with your application and add a
+ * dependency on the "ngIOS9Patch" module to your main app module.
+ *
+ * For example:
+ *
+ * ```
+ * angular.module('myApp', ['ngRoute'])`
+ * ```
+ *
+ * becomes
+ *
+ * ```
+ * angular.module('myApp', ['ngRoute', 'ngIOS9UIWebViewPatch'])
+ * ```
+ *
+ *
+ * More info:
+ * - https://openradar.appspot.com/22186109
+ * - https://github.com/angular/angular.js/issues/12241
+ * - https://github.com/driftyco/ionic/issues/4082
+ *
+ *
+ * @license AngularJS
+ * (c) 2010-2015 Google, Inc. http://angularjs.org
+ * License: MIT
+ */
+
+angular.module('ngIOS9UIWebViewPatch', ['ng']).config(function($provide) {
+ $provide.decorator('$browser', ['$delegate', '$window', function($delegate, $window) {
+
+ if (isIOS9UIWebView($window.navigator.userAgent)) {
+ return applyIOS9Shim($delegate);
+ }
+
+ return $delegate;
+
+ function isIOS9UIWebView(userAgent) {
+ return /(iPhone|iPad|iPod).* OS 9_\d/.test(userAgent) && !/Version\/9\./.test(userAgent);
+ }
+
+ function applyIOS9Shim(browser) {
+ var pendingLocationUrl = null;
+ var originalUrlFn= browser.url;
+
+ browser.url = function() {
+ if (arguments.length) {
+ pendingLocationUrl = arguments[0];
+ return originalUrlFn.apply(browser, arguments);
+ }
+
+ return pendingLocationUrl || originalUrlFn.apply(browser, arguments);
+ };
+
+ window.addEventListener('popstate', clearPendingLocationUrl, false);
+ window.addEventListener('hashchange', clearPendingLocationUrl, false);
+
+ function clearPendingLocationUrl() {
+ pendingLocationUrl = null;
+ }
+
+ return browser;
+ }
+ }]);
+});