bright-spark / css3-mediaqueries-js

Automatically exported from code.google.com/p/css3-mediaqueries-js
0 stars 0 forks source link

Bad addEventListener implementation for resize #20

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use Internet Explorer 6
2. Include css3-mediaqueries-js library on a page
3. Include other js frameworks on that page (i.e. Mootools, Ext)

What is the expected output? What do you see instead?
When other libraries are included, the window resize handler is not fired (like 
overwritten), so mediaqueries stop working on older browsers like IE6.

What version of the product are you using? On what operating system?
IE6, more specifically IETester with IE6 version enabled, on Windows 7 64-bit.

Please provide any additional information below.
To fix this you just need to change for a more cross-browser compatible version 
of adding event listeners. On line 947 replace this:

<code>
window.onresize = function () {
 var x = window.onresize || function () {}; // save original
 return function () {
  x();
  resizeHandler();
 };
}();
</code>

for this:

<code>
var addEvent = function(elem, type, eventHandle) {
 if (elem == null || elem == undefined) return;
 if ( elem.addEventListener ) {
  elem.addEventListener( type, eventHandle, false );
 } else if ( elem.attachEvent ) {
  elem.attachEvent( "on" + type, eventHandle );
 } else {
  elem["on"+type]=eventHandle;
 }
};
addEvent(window, 'resize', function(){
 resizeHandler();
});
</code>

Original issue reported on code.google.com by elbuen...@gmail.com on 14 Dec 2012 at 6:50

GoogleCodeExporter commented 9 years ago
Back from the dead... There is a new version of the script. It has some CSS 
parsing and processing improvements. If you're still using it, or would like to 
try again, could you confirm that this issue is solved or not?

Original comment by wou...@dynora.nl on 4 Apr 2014 at 11:46