Skip to content

Commit d3574b1

Browse files
committed
It is not possible for width to have a value in mounted().
It is only onWindowResize that sets width. And onWindowResize() gets called by mounted(), if self.$refs.item changes size (setup during mounted()) or in the watch for 'responsive'. In fact, there was a potential bug here. (I'm not sure how to trigger it, but bear with me): If a caller was to change this.responsive before mounted() was called, onWindowResize() would be called an that would set width to a non-null value. Because of that, these two would not be called during mount: self.initResponsiveFeatures(); addWindowEventListener('resize', self.onWindowResize); And they should. So all in all mounted() should not check for self.width == null
1 parent 9e13ea9 commit d3574b1

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/components/GridLayout.vue

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,13 @@
153153
this.originalLayout = this.layout;
154154
const self = this;
155155
this.$nextTick(function() {
156-
if (self.width === null) {
157-
self.onWindowResize();
156+
self.onWindowResize();
158157
159-
self.initResponsiveFeatures();
158+
self.initResponsiveFeatures();
159+
160+
//self.width = self.$el.offsetWidth;
161+
addWindowEventListener('resize', self.onWindowResize);
160162
161-
//self.width = self.$el.offsetWidth;
162-
addWindowEventListener('resize', self.onWindowResize);
163-
}
164163
compact(self.layout, self.verticalCompact);
165164
166165
self.updateHeight();

0 commit comments

Comments
 (0)