laminas / laminas-developer-tools

Module for developer and debug tools for use with laminas-mvc applications.
BSD 3-Clause "New" or "Revised" License
23 stars 13 forks source link

Javascript location.assign brokes the toolbar #10

Closed weierophinney closed 4 years ago

weierophinney commented 4 years ago

Hi!

When I use window.location.assign with a download link, the toolbar does not work properly and I get this javascript error on my console: Uncaught TypeError: Cannot read property 'offsetWidth' of null

Code to simulate:

<script type="text/javascript">
    window.location.assign("https://github.com/zendframework/ZendDeveloperTools/archive/master.zip");
</script>

Thank you!


Originally posted by @quintanilhar at https://github.com/zendframework/zend-developer-tools/issues/194

weierophinney commented 4 years ago

I don't see any offsetWidth being used? Doesn't look like this is the affected code?


Originally posted by @Ocramius at https://github.com/zendframework/zend-developer-tools/issues/194#issuecomment-138207189

weierophinney commented 4 years ago

Hi @Ocramius!

I can see the error in this code point:

<!-- START Zend Developer Toolbar JavaScript -->
<script type="text/javascript">
    <!--
    (function() {

    /**
     * @param {Cookie} cookie
     * @returns {Toolbar}
     * @constructor
     */
    var Toolbar = function(cookie) {
        /** @type {Toolbar} */
        var self = this;
        /** @type {HTMLElement} */
        var container = document.getElementById("zend-developer-toolbar");
        /** @type {number} */
        var width = container.offsetWidth; //<------- Uncaught TypeError: Cannot read property 'offsetWidth' of null

I tried to reproduce with a new application using the zf2 skeleton but in this case I missed the toolbar with the example code. You need to use a downloadable link to get the error as I pointed earlier.

Let me know if you need some more details.


Originally posted by @quintanilhar at https://github.com/zendframework/zend-developer-tools/issues/194#issuecomment-139114074

weierophinney commented 4 years ago

You need to use a downloadable link

I don't follow this bit, specifically...


Originally posted by @Ocramius at https://github.com/zendframework/zend-developer-tools/issues/194#issuecomment-139182179

weierophinney commented 4 years ago

@Ocramius, can you reproduce the error?


Originally posted by @quintanilhar at https://github.com/zendframework/zend-developer-tools/issues/194#issuecomment-142343378

samsonasik commented 4 years ago

I can't reproduce with latest laminas-developer-tools. I follow your location.assign() usage and can't reproduce the error.

Please re-create issue if problem persist with steps to reproduce. I'm closing it.