meetselva / attrchange

onattrchange listener
GNU General Public License v3.0
207 stars 57 forks source link

'onpropertychange' broken in IE 11 #13

Closed ExceptionLimeCat closed 9 years ago

ExceptionLimeCat commented 10 years ago

I ran across this issue the other day. You check for 'onpropertychange' at line 113 but then attach the listener to the 'propertychange' property. I had to change line 114 to say 'onpropertychange' to resolve this issue in IE 11. This obviously isn't backwards compatible but I did want to make sure this issue was known.

meetselva commented 10 years ago

The plugin uses 3 different methods to detect an attribute change

  1. Mutation Observer
  2. DOMAttrModified
  3. onpropertychange

and the plugin prefers to choose one of the above compatible methods based on the browser.

Regarding the issue,

  1. IE 11 supports MutationObserver and so the plugin would choose to use Mutation Observer as it is the preferred best method here. So I am guessing, that the same would have happened in your case.
  2. The onpropertychange is included as a method here to support older IE browsers < 9. See http://msdn.microsoft.com/en-us/library/ie/ms536956%28v=vs.85%29.aspx

Also The line 114 is the correct way to bind an event in jQuery. The 'on' is removed when binding an event in jQuery.

Please post a your code so I look into this in detail.

ExceptionLimeCat commented 10 years ago

I probably should have mentioned this was an issue in SharePoint Online... I'm not sure if you want to support that (wouldn't blame you if you didn't), but I will try and reproduce the issue. I basically had to force IE 11 to use the onpropertychange in order to capture when SharePoint sets the s4-bodyContainer element to a static height in the style attribute.

meetselva commented 10 years ago

I never had a chance to work on Share Point. I am adding some new features to the plugin soon which includes polling, which should work for you.

I will be closing this issue later today unless if I hear otherwise.

meetselva commented 9 years ago

Added extensions to the plugin which has polling. Refer to the examples https://github.com/meetselva/attrchange/blob/master/examples/ html for more information.

Rubidze commented 6 years ago

I have very similar problem with looking after s4-workspace container in SharePoint 2013. I'm using IE11, but SP adds to the header to avoid other compatibility issues. As a result Mutation Observer method doesn't work and attrchage is using DOMAttrModified method. I am using the code as simple as this:

$('#s4-workspace').attrchange({ trackValues: true, callback: function (e) { console.log(e.newValue) }});

I am getting results in console for changes that appear in #s4-workspace attributes, but I also get hundreds of records from other elements as well which is giving unnecessary load to the browser.

Any chances to limit to just selected element?