contao/core — Issue #3924: 2.11: Opera bug with chosen plugin width is still exists
Author: DyaGa
Created: 2012-02-10 15:41:21+00:00
State: open

This issue is related to #3627

![](http://gyazo.com/5fda60f0d86220a626887c2dfb76c816.png)

And, I think know why: **Opera doesn't return width and height value (and other styles) for hidden elements!**
Here are some bug reports I found:

* [getStyle and Opera](http://www.mooforum.net/general12/getstyle-and-opera-t3396.html)
* [[Moo] getStyle from not loaded Element in Opera](http://mootools-users.660466.n2.nabble.com/Moo-getStyle-from-not-loaded-Element-in-Opera-td5811710.html)
* [Element.getStyle('height') is wrong for hidden elements in Opera](https://prototype.lighthouseapp.com/projects/8886/tickets/487-elementgetstyle-and-getheight-and-opera-962)

Also, I try to make this in `chosen-uncompressed.js`:

```js
this.f_width = this.form_field.measure(function() {
// PATCH: measure elements in collapsed palettes (see #3627)
//return this.getSize().x;
console.log(this.getStyle('width').toInt());
console.log(this.style.width);
return (this.getSize().x > 0) ? this.getSize().x : this.getStyle('width').toInt();
});
```

and here is a result:

![](http://gyazo.com/f5ea4395fe725ebd36adc278449c4c83.png)

It returns `-4` and ` ` (empty) values. Also code `console.log(document.getElementById('gx3g2ktm').style.width)` have the same result.

So, this happens only in Opera. I can propose this solution: add `data-width` attribute for every select element and then in `chosen-uncompressed.js` use this:

```js
this.f_width = this.form_field.measure(function() {
// PATCH: measure elements in collapsed palettes (see #3627)
//return this.getSize().x;
return (this.getSize().x > 0) ? this.getSize().x : this.get('data-width').toInt();
});
```

and use something like that: http://stackoverflow.com/a/7141517