Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save davidbaiguini/1f1214f3b5371b9c2012 to your computer and use it in GitHub Desktop.
Save davidbaiguini/1f1214f3b5371b9c2012 to your computer and use it in GitHub Desktop.

Revisions

  1. @IgorMinar IgorMinar revised this gist Sep 18, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion angular-ios9-uiwebview.patch.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    /**
    * ================== angular-ios9-uiwebview.patch.js v1.1.0 ==================
    * ================== angular-ios9-uiwebview.patch.js v1.1.1 ==================
    *
    * This patch works around iOS9 UIWebView regression that causes infinite digest
    * errors in Angular.
  2. @IgorMinar IgorMinar revised this gist Sep 18, 2015. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions angular-ios9-uiwebview.patch.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    * 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.
    * dependency on the "ngIOS9UIWebViewPatch" module to your main app module.
    *
    * For example:
    *
    @@ -34,7 +34,9 @@
    * License: MIT
    */

    angular.module('ngIOS9UIWebViewPatch', ['ng']).config(function($provide) {
    angular.module('ngIOS9UIWebViewPatch', ['ng']).config(['$provide', function($provide) {
    'use strict';

    $provide.decorator('$browser', ['$delegate', '$window', function($delegate, $window) {

    if (isIOS9UIWebView($window.navigator.userAgent)) {
    @@ -70,4 +72,4 @@ angular.module('ngIOS9UIWebViewPatch', ['ng']).config(function($provide) {
    return browser;
    }
    }]);
    });
    }]);
  3. @IgorMinar IgorMinar revised this gist Sep 11, 2015. 1 changed file with 13 additions and 11 deletions.
    24 changes: 13 additions & 11 deletions angular-ios9-uiwebview.patch.js
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,14 @@
    /**
    * ============================ angular-ios9-uiwebview.patch.js v1.0.3 ============================
    *
    * This patch works around iOS9 UIWebView regression that causes infinite digest errors in Angular.
    * ================== angular-ios9-uiwebview.patch.js v1.1.0 ==================
    *
    * The patch can be applied to Angular 1.2.0 – 1.4.5. Newer versions of Angular have the workaround baked in.
    * This patch works around iOS9 UIWebView regression that causes infinite digest
    * errors in Angular.
    *
    * To apply this patch load/bundle this file with your application and add a dependency on the "ngIOS9Patch" module
    * to your main app module.
    * 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:
    *
    @@ -47,15 +49,15 @@ angular.module('ngIOS9UIWebViewPatch', ['ng']).config(function($provide) {

    function applyIOS9Shim(browser) {
    var pendingLocationUrl = null;
    var patchedBrowser = Object.create(browser);
    var originalUrlFn= browser.url;

    patchedBrowser.url = function() {
    browser.url = function() {
    if (arguments.length) {
    pendingLocationUrl = arguments[0];
    return browser.url.apply(patchedBrowser, arguments);
    return originalUrlFn.apply(browser, arguments);
    }

    return pendingLocationUrl || browser.url();
    return pendingLocationUrl || originalUrlFn.apply(browser, arguments);
    };

    window.addEventListener('popstate', clearPendingLocationUrl, false);
    @@ -65,7 +67,7 @@ angular.module('ngIOS9UIWebViewPatch', ['ng']).config(function($provide) {
    pendingLocationUrl = null;
    }

    return patchedBrowser;
    return browser;
    }
    }]);
    });
  4. @IgorMinar IgorMinar revised this gist Sep 11, 2015. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion angular-ios9-uiwebview.patch.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    /**
    * ============================ angular-ios9-uiwebview.patch.js v1.0.3 ============================
    *
    * 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.
    @@ -40,7 +42,7 @@ angular.module('ngIOS9UIWebViewPatch', ['ng']).config(function($provide) {
    return $delegate;

    function isIOS9UIWebView(userAgent) {
    return /(iPhone|iPad|iPod) OS 9_\d/.test(userAgent) && !/Version\/9\./.test(userAgent);
    return /(iPhone|iPad|iPod).* OS 9_\d/.test(userAgent) && !/Version\/9\./.test(userAgent);
    }

    function applyIOS9Shim(browser) {
  5. @IgorMinar IgorMinar revised this gist Sep 11, 2015. 1 changed file with 28 additions and 26 deletions.
    54 changes: 28 additions & 26 deletions angular-ios9-uiwebview.patch.js
    Original file line number Diff line number Diff line change
    @@ -30,38 +30,40 @@
    * License: MIT
    */

    angular.module('ngIOS9UIWebViewPatch', ['ng']).decorator('$browser', ['$delegate', '$window', function($delegate, $window) {
    angular.module('ngIOS9UIWebViewPatch', ['ng']).config(function($provide) {
    $provide.decorator('$browser', ['$delegate', '$window', function($delegate, $window) {

    if (isIOS9UIWebView($window.navigator.userAgent)) {
    return applyIOS9Shim($delegate);
    }
    if (isIOS9UIWebView($window.navigator.userAgent)) {
    return applyIOS9Shim($delegate);
    }

    return $delegate;
    return $delegate;

    function isIOS9UIWebView(userAgent) {
    return /(iPhone|iPad|iPod) OS 9_\d/.test(userAgent) && !/Version\/9\./.test(userAgent);
    }
    function isIOS9UIWebView(userAgent) {
    return /(iPhone|iPad|iPod) OS 9_\d/.test(userAgent) && !/Version\/9\./.test(userAgent);
    }

    function applyIOS9Shim(browser) {
    var pendingLocationUrl = null;
    var patchedBrowser = Object.create(browser);
    function applyIOS9Shim(browser) {
    var pendingLocationUrl = null;
    var patchedBrowser = Object.create(browser);

    patchedBrowser.url = function() {
    if (arguments.length) {
    pendingLocationUrl = arguments[0];
    return browser.url.apply(patchedBrowser, arguments);
    }
    patchedBrowser.url = function() {
    if (arguments.length) {
    pendingLocationUrl = arguments[0];
    return browser.url.apply(patchedBrowser, arguments);
    }

    return pendingLocationUrl || browser.url();
    };
    return pendingLocationUrl || browser.url();
    };

    window.addEventListener('popstate', clearPendingLocationUrl, false);
    window.addEventListener('hashchange', clearPendingLocationUrl, false);
    window.addEventListener('popstate', clearPendingLocationUrl, false);
    window.addEventListener('hashchange', clearPendingLocationUrl, false);

    function clearPendingLocationUrl() {
    pendingLocationUrl = null;
    }
    function clearPendingLocationUrl() {
    pendingLocationUrl = null;
    }

    return patchedBrowser;
    }
    }]);
    return patchedBrowser;
    }
    }]);
    });
  6. @IgorMinar IgorMinar created this gist Sep 11, 2015.
    67 changes: 67 additions & 0 deletions angular-ios9-uiwebview.patch.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,67 @@
    /**
    * 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']).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 patchedBrowser = Object.create(browser);

    patchedBrowser.url = function() {
    if (arguments.length) {
    pendingLocationUrl = arguments[0];
    return browser.url.apply(patchedBrowser, arguments);
    }

    return pendingLocationUrl || browser.url();
    };

    window.addEventListener('popstate', clearPendingLocationUrl, false);
    window.addEventListener('hashchange', clearPendingLocationUrl, false);

    function clearPendingLocationUrl() {
    pendingLocationUrl = null;
    }

    return patchedBrowser;
    }
    }]);