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

[FIX] svg render on firefox #9311

Merged
merged 5 commits into from
Jan 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/rocketchat-ui-master/client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import s from 'underscore.string';

RocketChat.settings.collection.find({_id:/theme-color-rc/i}, {fields:{ value: 1 }}).observe({changed: () => { DynamicCss.run(true); }});

this.isFirefox = navigator.userAgent.match(/Firefox\/(\d+)\.\d/);

Template.body.onRendered(function() {
new Clipboard('.clipboard');

Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-ui/client/components/icon.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template name="icon">
<svg class="rc-icon {{block}} {{block}}--{{icon}} {{classes}}" aria-hidden="true">
<use xlink:href="#icon-{{icon}}"></use>
<use xlink:href="{{baseUrl}}#icon-{{icon}}"></use>
</svg>
</template>
7 changes: 7 additions & 0 deletions packages/rocketchat-ui/client/components/icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* globals isFirefox */

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const baseUrl = isFirefox ? () => window.location.href.replace(window.location.hash, '') : () => ""

Template.icon.helpers({ baseUrl })

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ggazzo Why??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the isFirefox check run only one time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @karlprieb

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if will run only one time, but replace (much heavy) will continue running every time.

I don't see much performance improvement for such non readable code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That function will run over 50 times on every route change, thats why we shouldn't check if is firefox every time.

const firefoxBaseUrlFix = () => `${ window.location.origin }${ FlowRouter.current().path }`;

Template.icon.helpers({
baseUrl: isFirefox && isFirefox[1] < 55 ? firefoxBaseUrlFix : undefined
});
1 change: 1 addition & 0 deletions packages/rocketchat-ui/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ Package.onUse(function(api) {
api.addFiles('client/views/app/photoswipe.js', 'client');

api.addFiles('client/components/icon.html', 'client');
api.addFiles('client/components/icon.js', 'client');

api.addFiles('client/components/popupList.html', 'client');
api.addFiles('client/components/popupList.js', 'client');
Expand Down