This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.3k
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
reloadWithDebugInfo does not work when the host already uses window.name #13031
Copy link
Copy link
Open
Milestone
Description
I am not sure how much of an edge case this is, but the reloadWithDebugInfo
call relies on window.name
not to be used outside of angular.
We have a script-tag in our head setting the window.name
for our application, this causes the implementation for reloadWithDebugInfo
not to work.
Lines 1600 to 1638 in 19ecdb5
var NG_ENABLE_DEBUG_INFO = /^NG_ENABLE_DEBUG_INFO!/; | |
var NG_DEFER_BOOTSTRAP = /^NG_DEFER_BOOTSTRAP!/; | |
if (window && NG_ENABLE_DEBUG_INFO.test(window.name)) { | |
config.debugInfoEnabled = true; | |
window.name = window.name.replace(NG_ENABLE_DEBUG_INFO, ''); | |
} | |
if (window && !NG_DEFER_BOOTSTRAP.test(window.name)) { | |
return doBootstrap(); | |
} | |
window.name = window.name.replace(NG_DEFER_BOOTSTRAP, ''); | |
angular.resumeBootstrap = function(extraModules) { | |
forEach(extraModules, function(module) { | |
modules.push(module); | |
}); | |
return doBootstrap(); | |
}; | |
if (isFunction(angular.resumeDeferredBootstrap)) { | |
angular.resumeDeferredBootstrap(); | |
} | |
} | |
/** | |
* @ngdoc function | |
* @name angular.reloadWithDebugInfo | |
* @module ng | |
* @description | |
* Use this function to reload the current application with debug information turned on. | |
* This takes precedence over a call to `$compileProvider.debugInfoEnabled(false)`. | |
* | |
* See {@link ng.$compileProvider#debugInfoEnabled} for more. | |
*/ | |
function reloadWithDebugInfo() { | |
window.name = 'NG_ENABLE_DEBUG_INFO!' + window.name; | |
window.location.reload(); | |
} |
Angular version: 1.4 (but I assume this applies to 1.3 as well)
Browser: every browser
Reproduce: add a script tag with window.name = 'some name'
in your page head, disable debug info in your config, confirm angular.reloadWithDebugInfo()
does not work
Suggested fixes:
- maybe use a query string parameter instead? Seems to me like
NG_ENABLE_DEBUG_INFO!
won't be a widely used query string? - use a cookie: if you use a cookie, you can let it expire with the session, and it would be possible to implement a
reloadWithDebugInfo(false)
call to reset it - use local storage: similar as cookie, this is more persistent
superole