zend-developer-tools icon indicating copy to clipboard operation
zend-developer-tools copied to clipboard

Javascript location.assign brokes the toolbar

Open quintanilhar opened this issue 10 years ago • 5 comments

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!

quintanilhar avatar Sep 07 '15 05:09 quintanilhar

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

Ocramius avatar Sep 07 '15 06:09 Ocramius

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.

quintanilhar avatar Sep 10 '15 04:09 quintanilhar

You need to use a downloadable link

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

Ocramius avatar Sep 10 '15 09:09 Ocramius

@Ocramius, can you reproduce the error?

quintanilhar avatar Sep 22 '15 16:09 quintanilhar

This repository has been closed and moved to laminas/laminas-developer-tools; a new issue has been opened at https://github.com/laminas/laminas-developer-tools/issues/10.

weierophinney avatar Dec 31 '19 22:12 weierophinney