Skip to content

Commit 0838470

Browse files
committed
Auto merge of #2994 - Turbo87:ember-link, r=locks
Use `ember-link` for links in lists Using `LinkTo` can be "bad" for performance when used in loops since it still uses `Ember.Component` underneath. This PR switches two components to use https://github.com/buschtoens/ember-link instead, which should slightly improve the rendering times. It also significantly simplifies the API of the `FrontPageList::Item` component.
2 parents 3962b74 + e632c74 commit 0838470

File tree

5 files changed

+63
-25
lines changed

5 files changed

+63
-25
lines changed

app/components/crate-row.hbs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
<div local-class="crate-row" data-test-crate-row ...attributes>
22
<div local-class="description-box">
33
<div>
4-
<LinkTo
5-
@route="crate"
6-
@model={{@crate.id}}
7-
local-class="name"
8-
data-test-crate-link
9-
>
10-
{{ @crate.name }}
11-
</LinkTo>
4+
{{#let (link "crate" @crate.id) as |l|}}
5+
<a href={{l.url}} local-class="name" data-test-crate-link {{on "click" l.transitionTo}}>
6+
{{@crate.name}}
7+
</a>
8+
{{/let}}
129
<span local-class="version" data-test-version>v{{@crate.max_version}}</span>
1310
<CopyButton
1411
@copyText='{{@crate.name}} = "{{@crate.max_version}}"'
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<LinkTo @route={{@route}} @model={{@model}} local-class="link" ...attributes>
1+
<a href={{@link.url}} local-class="link" ...attributes {{on "click" @link.transitionTo}}>
22
<div local-class="left">
33
<div local-class="title">{{@title}}</div>
44
{{#if @subtitle}}<div local-class="subtitle">{{@subtitle}}</div>{{/if}}
55
</div>
66
{{svg-jar "chevron-right" local-class="right"}}
7-
</LinkTo>
7+
</a>

app/templates/index.hbs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@
7373
{{#each this.model.new_crates as |crate index|}}
7474
<li>
7575
<FrontPageList::Item
76-
@route="crate"
77-
@model={{crate.id}}
76+
@link={{link "crate" crate.id}}
7877
@title={{crate.name}}
7978
@subtitle="v{{crate.newest_version}}"
8079
data-test-crate-link={{index}}
@@ -98,8 +97,7 @@
9897
{{#each this.model.most_downloaded as |crate index|}}
9998
<li>
10099
<FrontPageList::Item
101-
@route="crate"
102-
@model={{crate.id}}
100+
@link={{link "crate" crate.id}}
103101
@title={{crate.name}}
104102
data-test-crate-link={{index}}
105103
/>
@@ -122,8 +120,7 @@
122120
{{#each this.model.just_updated as |crate index|}}
123121
<li>
124122
<FrontPageList::Item
125-
@route="crate"
126-
@model={{crate.id}}
123+
@link={{link "crate" crate.id}}
127124
@title={{crate.name}}
128125
@subtitle="v{{crate.newest_version}}"
129126
data-test-crate-link={{index}}
@@ -147,8 +144,7 @@
147144
{{#each this.model.most_recently_downloaded as |crate index|}}
148145
<li>
149146
<FrontPageList::Item
150-
@route="crate"
151-
@model={{crate.id}}
147+
@link={{link "crate" crate.id}}
152148
@title={{crate.name}}
153149
data-test-crate-link={{index}}
154150
/>
@@ -171,8 +167,7 @@
171167
{{#each this.model.popular_keywords as |keyword|}}
172168
<li>
173169
<FrontPageList::Item
174-
@route="keyword"
175-
@model={{keyword}}
170+
@link={{link "keyword" keyword}}
176171
@title={{keyword.id}}
177172
@subtitle="{{format-num keyword.crates_cnt}} crates"
178173
/>
@@ -195,8 +190,7 @@
195190
{{#each this.model.popular_categories as |category|}}
196191
<li>
197192
<FrontPageList::Item
198-
@route="category"
199-
@model={{category.slug}}
193+
@link={{link "category" category.slug}}
200194
@title={{category.category}}
201195
@subtitle="{{format-num category.crates_cnt}} crates"
202196
/>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"ember-export-application-global": "2.0.1",
8787
"ember-fetch": "8.0.2",
8888
"ember-keyboard": "6.0.2",
89+
"ember-link": "^1.1.1",
8990
"ember-load-initializers": "2.1.1",
9091
"ember-maybe-import-regenerator": "0.1.6",
9192
"ember-modifier": "2.1.1",

yarn.lock

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@
13891389
"@handlebars/parser" "^1.1.0"
13901390
simple-html-tokenizer "^0.5.9"
13911391

1392-
"@glimmer/[email protected]":
1392+
"@glimmer/[email protected]", "@glimmer/tracking@~1.0.1":
13931393
version "1.0.2"
13941394
resolved "https://registry.yarnpkg.com/@glimmer/tracking/-/tracking-1.0.2.tgz#4fe9ca89e3f4a2ae8e37c8bd8e4ea0d886d9abbf"
13951395
integrity sha512-9Vp04TM2IDTShGFdxccfvnmcaj4NwqLrwbOXm4iju5KL/WkeB8mqoCSLtO3kUg+80DqU0pKE8tR460lQP8CutA==
@@ -5971,7 +5971,7 @@ ember-assign-polyfill@^2.5.0, ember-assign-polyfill@^2.6.0:
59715971
ember-cli-babel "^7.20.5"
59725972
ember-cli-version-checker "^2.0.0"
59735973

5974-
[email protected], ember-auto-import@^1.2.19:
5974+
59755975
version "1.7.0"
59765976
resolved "https://registry.yarnpkg.com/ember-auto-import/-/ember-auto-import-1.7.0.tgz#dd809fbe3d40647f2af443072405094d0e77ecf5"
59775977
integrity sha512-onp7XZKwiit3BgkOPV/obi3fvLJmDNKTTjRsVtYz63yWeyT3ahiM8BIvJYzHGL4cxlGLvwpTJy2HYBDs6ZtvoQ==
@@ -6005,6 +6005,40 @@ [email protected], ember-auto-import@^1.2.19:
60056005
walk-sync "^0.3.3"
60066006
webpack "^4.43.0"
60076007

6008+
ember-auto-import@^1.2.19, ember-auto-import@^1.6.0:
6009+
version "1.6.0"
6010+
resolved "https://registry.yarnpkg.com/ember-auto-import/-/ember-auto-import-1.6.0.tgz#00a498172b04f7084a5d2a327f76f577038ed403"
6011+
integrity sha512-BRBrmbDXRuXG/WYbn/2DXM7bFNyQuT80du1scUrrX0+xFVkDOU08s46ZPCvzYprzSg2htgrztQ/nVdnfbIBV+Q==
6012+
dependencies:
6013+
"@babel/core" "^7.1.6"
6014+
"@babel/preset-env" "^7.10.2"
6015+
"@babel/traverse" "^7.1.6"
6016+
"@babel/types" "^7.1.6"
6017+
"@embroider/core" "^0.4.3"
6018+
babel-core "^6.26.3"
6019+
babel-loader "^8.0.6"
6020+
babel-plugin-syntax-dynamic-import "^6.18.0"
6021+
babel-template "^6.26.0"
6022+
babylon "^6.18.0"
6023+
broccoli-debug "^0.6.4"
6024+
broccoli-plugin "^1.3.0"
6025+
debug "^3.1.0"
6026+
ember-cli-babel "^6.6.0"
6027+
enhanced-resolve "^4.0.0"
6028+
fs-extra "^6.0.1"
6029+
fs-tree-diff "^1.0.0"
6030+
handlebars "^4.3.1"
6031+
js-string-escape "^1.0.1"
6032+
lodash "^4.17.10"
6033+
mkdirp "^0.5.1"
6034+
pkg-up "^2.0.0"
6035+
resolve "^1.7.1"
6036+
rimraf "^2.6.2"
6037+
symlink-or-copy "^1.2.0"
6038+
typescript-memoize "^1.0.0-alpha.3"
6039+
walk-sync "^0.3.3"
6040+
webpack "~4.28"
6041+
60086042
60096043
version "4.0.0"
60106044
resolved "https://registry.yarnpkg.com/ember-cli-app-version/-/ember-cli-app-version-4.0.0.tgz#033057ec5fe4d3ecdf5ac5380d442e2dc9f7526a"
@@ -6802,6 +6836,18 @@ [email protected]:
68026836
ember-compatibility-helpers "^1.2.1"
68036837
ember-modifier "^2.1.0"
68046838

6839+
ember-link@^1.1.1:
6840+
version "1.2.0"
6841+
resolved "https://registry.yarnpkg.com/ember-link/-/ember-link-1.2.0.tgz#8145da3ac25a7c84110bb611ccd0d7eea13103d1"
6842+
integrity sha512-UYfljC5rGcKTqWneR6z2Ap8HaySfhs0U2gxC3fSEyXcR0GTdZGlouQAxy8QRLLdqYgU7tymfJGRS+c1VUsesgQ==
6843+
dependencies:
6844+
"@glimmer/tracking" "~1.0.1"
6845+
ember-auto-import "^1.6.0"
6846+
ember-cli-babel "^7.22.1"
6847+
ember-cli-htmlbars "^5.2.0"
6848+
ember-cli-typescript "^3.1.4"
6849+
fast-json-stable-stringify "^2.1.0"
6850+
68056851
68066852
version "2.1.1"
68076853
resolved "https://registry.yarnpkg.com/ember-load-initializers/-/ember-load-initializers-2.1.1.tgz#d1a8bead00bc44222b0ab181840869992beb30f5"
@@ -7750,7 +7796,7 @@ fast-glob@^3.0.3, fast-glob@^3.1.1:
77507796
micromatch "^4.0.2"
77517797
picomatch "^2.2.1"
77527798

7753-
fast-json-stable-stringify@^2.0.0:
7799+
fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0:
77547800
version "2.1.0"
77557801
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"
77567802
integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==

0 commit comments

Comments
 (0)