-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
Turbolinks and observeMutations problem #12709
Comments
I have this issue too... exactly as described above. For the time being, I've reverted back to the CSS CDN which works, but it would be nice if FontAwesome (JS) could play nicely with Turbolinks! |
I think we have an idea how we can elegantly fix this. It's on the list and high priority. |
@montulli Could you try to use the new invoke I think that would attach the mutation observer to the higher Again, you'd need to make sure you're using all of the new Font Awesome 5.1 packages. Here are upgrade instructions. |
@mlwilkerson as a RoR developer, I'm trying this solution myself Anyway, it doesn't seem to work on localhost and I can't show you at the moment the results because deploy on Heroku doesn't work:
yarn.lock: https://github.com/diowa/ruby2-rails5-bootstrap-heroku/blob/master/yarn.lock#L5-L31 Anyway, the result is still the same of the old deploy: https://ruby2-rails5-bootstrap-heroku.herokuapp.com/ (try to click on "hello world") edit I was able to deploy a version with https://ruby2-rails5-bootstrap-heroku.herokuapp.com/ Click on "Rails 5 Starter App" in the navbar or on "Hello world" and the github icon will disappear You can confirm that |
@tagliala thanks for giving it a try. Can you verify what version of In particular, it looks like the code that handles that |
@tagliala if you get a moment can you try |
I've deleted the downloaded tgz
and does not contain instances of tried with |
@tagliala we are at 1.2.0-14 on the |
Sorry, Thanks, now it works for me 👍 I'm using svg core version |
@tagliala Great! Thanks for giving it a try. Now, I think we need an easy step-by-step guide to help others get it working too. Do you have a "hello world"-level minimal demo repo that shows how you've configured this? If so, I might take that as a starting point. |
I can definitely help, I will work on it tomorrow The previous app is a pretty basic rails 5.2 with webpacker configuration. It supports tree shaking out of the box. We have different options in rails, including Is there a way to configure |
I think we are trying to find out if we can change the default to |
(I could actually answer your question). No, this is not a config option yet. |
please take a look here: https://github.com/tagliala/fontawesome5demo#readme Each commit contains what needs to be done in the command line to achieve that result The main effort is to get into the webpacker ecosystem, then Font Awesome is just another package. At the moment, I don't know how to make it work without webpacker. Please let me know when (and if) you change the default observer to |
Works properly, the only annoyance I noticed is a flicker on the reload. |
I suppose that we cannot fix the flickering. I would like to implement a rails gem for server side icon rendering Ref: |
Thanks for the demo, @tagliala. |
@tagliala I think we can fix the flickering actually. The reason that it happens is that the icons are replaced async. We can make this process synchronous for the Turbolinks version. |
Any updates? |
@paicha update on what? |
Make icons replace process synchronous for the Turbolinks version.
Geremia Taglialatela <notifications@github.com>
… @paicha <https://github.com/paicha> update on what?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#12709 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE6OVSlA8LS3tPF2ybFRDF8KdP8OwY9Xks5uLurrgaJpZM4S8JmJ>
.
|
Heads-up: Font Awesome 5.7.0 supports turbolinks out of the box. // FA < 5.7.0 (>= 5.1.0)
dom.watch({ observeMutationsRoot: document })
// FA >= 5.7.0
dom.watch() |
I believe this issue can be closed. |
...Why is this still opened? 😅 @sunnyrjuneja thanks for the heads-up! |
I have a rails project with turbolinks classic and I am trying to use the new SVG version of font-awesome 5.
The font-awesome.js file loads once and bootstrap() runs once when it loads. After the initial load turbolinks does a dom replacement of each additional page load and skips the reloading of all the js files.
When the dom is replaced by turbolinks I call i2svg() and the icon classes within the new html are replaced with SVGs.
The problem I am having is that JS changes to the classes to swap out icons do not work on subsequent dom loads. They work on the first load, since bootstrap calls 'observe' to watch for mutations, but on subsequent loads using i2svg(), observe() is not called so that part of the DOM is not changing when icons are supposed to change. (fa-chevron-right and fa-chevron-down swaps are a simple example)
I tried adding the code at the bottom to i2svg(), but it caused my app to start taking multiple seconds to load subsequent pages. I suspect that I'm causing N squared observations and I need something that clears the old observers and just inserts the new ones.
Here is the code I added to i2svg. It did make js icons swaps work, but performance was too slow:
if (config.observeMutations && typeof MutationObserver === 'function') {
observe({
treeCallback: onTree,
nodeCallback: onNode,
pseudoElementsCallback: searchPseudoElements
});
}
The text was updated successfully, but these errors were encountered: