css-element-queries icon indicating copy to clipboard operation
css-element-queries copied to clipboard

ResizeSensor: Cannot set property 'detach' of undefined"

Open huashengwang1989 opened this issue 7 years ago • 9 comments

ResizeSensor throws an error: Error in directive resize update hook: "TypeError: Cannot set property 'detach' of undefined"

Chrome points me to these lines:

this.detach = function (ev) {
            ResizeSensor.detach(element, ev);
};

As in strict mode, this is undefined here. Changing it to arrow function can solve the problem.

huashengwang1989 avatar Aug 25 '17 08:08 huashengwang1989

Weird, works here. Arrow functions are not possible right now due to the browser support. Which browser version do you have?

marcj avatar Dec 22 '17 14:12 marcj

Same issue here, my browser version is Version 63.0.3239.84

qianlifeng avatar Dec 27 '17 02:12 qianlifeng

+1

Same issue occurs on

  • Safari 11.0.2
  • Chrome 63.0.3239.84
  • Firefox 57.0.3

Interesting thing is that it does not throw on dev environment.

arslanyunus avatar Jan 03 '18 08:01 arslanyunus

Should be fixed, will be part of the next version 1.0.0 in the next hours.

marcj avatar Jan 08 '18 23:01 marcj

Still having the same problem using 1.0.1. It works when downgrading to 0.4.0.

TypeError: Cannot set property 'detach' of undefined
    at ResizeSensor (ResizeSensor.js?705e:229)
    at inserted (onResize.js?f81a:35)
    at callHook$1 (vue.esm.js?efeb:6197)
    at callInsert (vue.esm.js?efeb:6136)
    at wrappedHook (vue.esm.js?efeb:2057)
    at Object.invoker [as insert] (vue.esm.js?efeb:2000)
    at invokeInsertHook (vue.esm.js?efeb:5864)
    at VueComponent.patch [as __patch__] (vue.esm.js?efeb:6083)
    at VueComponent.Vue._update (vue.esm.js?efeb:2647)
    at VueComponent.updateComponent (vue.esm.js?efeb:2765)

SteffenDE avatar Jan 14 '18 14:01 SteffenDE

Now sure how to reproduce. I tested in all modern Browser version (Chrome, Firefox, Internet Explorer, Safari) and don't get the error - See the example page http://marcj.github.io/css-element-queries/. Maybe it has something todo with your build steps.

marcj avatar Jan 14 '18 19:01 marcj

I'm using css-element-queries with webpack and babel. Commenting out the JS strict mode solves this issue for me.

http://marcj.github.io/css-element-queries/ packs ResizeSensor in "app.js" and there is no "use strict" in it, so the issue doesn't affect the demo page, I guess. Edit: my fault, strict mode is active in the demo, I just didn't see it while searching for "use strict" (double quotes)..

SteffenDE avatar Jan 14 '18 20:01 SteffenDE

Seems like this was already fixed on https://github.com/marcj/css-element-queries/pull/168 Could you take a look at guys?

eduardomoroni avatar Feb 25 '19 10:02 eduardomoroni

@eduardomoroni Still the same issue on 1.2.2 with VueJS.

EDIT: Nevermind I'm an idiot I just forgot to call the ResizeSensor constructor, thus causing this to be undefined.

geauser avatar Dec 17 '19 07:12 geauser