Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change asap mutation observer implementation to touch text node #2

Closed
wants to merge 1 commit into from
Closed

Conversation

josh
Copy link
Contributor

@josh josh commented Dec 18, 2013

Alternative PR to #1 as suggested by @azakus.

Opposed to setting attribute to the same value which may not trigger a mutation on buggy browsers or with a MutationObserver polyfill.

Hat tip to Polymer microtask.js
https://github.com/Polymer/platform-dev/blob/master/src/microtask.js

/cc @jakearchibald @azakus

Opposed to setting attribute to the same value which may not trigger
a mutation on buggy browsers or with a MutationObserver polyfill.

Hat tip to Polymer microtask.js
https://github.com/Polymer/platform-dev/blob/master/src/microtask.js
@jakearchibald
Copy link
Collaborator

Looks good to me, but this polyfill is based on https://github.com/tildeio/rsvp.js/, and they'd benefit from the change too. I landed a commit over there a couple of days ago, once you land this I'll merge them in here and ship a new version.

Regarding the patch:

  • I'm not sure what the browser support of the mutation polyfill is like, but textnode.data has better support than textnode.textContent (goes back to IE6, perhaps earlier) and it's fewer bytes
  • I guess it's unlikely for iterations to get too big, but is (iterations = ++iterations % 2) better than iterations++?

I'll leave this open until I merge from rsvp

@josh
Copy link
Contributor Author

josh commented Dec 18, 2013

@domenic
Copy link
Contributor

domenic commented Dec 18, 2013

-1. This is working as designed. When you use a MutationObserver polyfill, you explicitly opt in to flushing the queue yourself. If you don't flush the queue, then no promise handlers should fire. When you flush the queue, they should fire.

@domenic
Copy link
Contributor

domenic commented Dec 18, 2013

Wait. I didn't understand the change. So the MutationObserver polyfill is just buggy, and only requires explicit flush of the queue when you edit attributes? Well, I guess working around that bug is less bad. But why not submit a pull request to polymer to fix their polyfill to not trigger the bug in the first place?

@josh
Copy link
Contributor Author

josh commented Dec 18, 2013

Its not practically unfixable since DOMAttrModified doesn't fire if the attribute is set to the same value. PR #1 suggested not trusting a non-native implementation in the first place.

@domenic
Copy link
Contributor

domenic commented Dec 18, 2013

Doesn't onpropertychange fire? Meh. I'm sure the polymer folks have already looked into this. Seems fine. Sorry for the initial negativity.

@stefanpenner
Copy link
Owner

@domenic can we confirm the polymer folks have looked into this? (I am not quite sure how they would work around this)

@josh
Copy link
Contributor Author

josh commented Dec 18, 2013

tildeio/rsvp.js@3f75248

@josh
Copy link
Contributor Author

josh commented Dec 18, 2013

@jakearchibald if you're just going to resync rspv.js source, I can close this.

@jakearchibald
Copy link
Collaborator

Changes went into rsvp.js, have been merged, new version (0.1.1) released with the changes \o/

@josh many thanks for this!

@stefanpenner
Copy link
Owner

Pretty cool, I didn't realize RSVP was used as the polyfil.

Keep me posted if you have any issues/ideas.

@josh josh deleted the microtask branch December 19, 2013 15:41
@jakearchibald
Copy link
Collaborator

Great isn't it? Looks like I did loads of work, but really it was just a few hours of deleting, renaming & making sure inheritance worked as spec'd.

(although I do point out the link in the first link of the readme, I'm not a total cretin)

medikoo added a commit to medikoo/next-tick that referenced this pull request Apr 18, 2014
phil-davis added a commit to owncloud/core that referenced this pull request Mar 20, 2019
phil-davis added a commit to owncloud/core that referenced this pull request May 30, 2019
phil-davis added a commit to owncloud/core that referenced this pull request Jun 7, 2019
phil-davis added a commit to owncloud/core that referenced this pull request Jun 11, 2019
phil-davis added a commit to owncloud/core that referenced this pull request Jun 12, 2019
phil-davis added a commit to owncloud/core that referenced this pull request Jun 20, 2019
phil-davis added a commit to owncloud/core that referenced this pull request Jun 24, 2019
phil-davis added a commit to owncloud/core that referenced this pull request Jun 24, 2019
phil-davis added a commit to owncloud/core that referenced this pull request Jun 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants