Skip to content

Ember version update (3.20.4 -> 3.22.0) + attempt to use custom each #814

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

Merged
merged 3 commits into from
Nov 1, 2020
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
9 changes: 9 additions & 0 deletions frameworks/keyed/ember/app/components/fast-each.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<table {{did-insert this.createRef}} ...attributes>
</table>
{{#if this.fragment}}
{{#-in-element this.fragment}}
<tbody>
{{#each @items key="id" as |item|}}{{yield item}}{{/each}}
</tbody>
{{/-in-element}}
{{/if}}
26 changes: 26 additions & 0 deletions frameworks/keyed/ember/app/components/fast-each.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { scheduleOnce, cancel } from '@ember/runloop';
export default class FastEachComponent extends Component {
@tracked fragment = null;
t1 = null;
t2 = null;
@action createRef(node) {
this.node = node;
this.fragment = document.createDocumentFragment();
this.t1 = scheduleOnce('afterRender', this, this.runAppend);
}
willDestroy() {
cancel(this.t1);
clearTimeout(this.t2);
}
@action runAppend() {
this.t2 = setTimeout(()=>{
this.appendFragment();
});
}
@action appendFragment() {
this.node.appendChild(this.fragment);
}
}
2 changes: 1 addition & 1 deletion frameworks/keyed/ember/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Ember v3.20.4</title>
<title>Ember v3.22.0</title>
<meta name="description" content="">

{{content-for "head"}}
Expand Down
12 changes: 4 additions & 8 deletions frameworks/keyed/ember/app/templates/components/my-table.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="jumbotron">
<div class="row">
<div class="col-md-6">
<h1>Ember v3.20.4</h1>
<h1>Ember v3.22.0</h1>
</div>
<div class="col-md-6">
<div class="row">
Expand Down Expand Up @@ -42,13 +42,9 @@


{{#if this.data.length}}
<table class="table table-hover table-striped test-data">
<tbody>
{{#each this.data key="id" as |item|}}
<TableRow @item={{item}} @onSelect={{fn this.select item.id}} @onRemove={{fn this.remove item.id}} />
{{/each}}
</tbody>
</table>
<FastEach class="table table-hover table-striped test-data" @items={{this.data}} as |item|>
<TableRow @item={{item}} @onSelect={{fn this.select item.id}} @onRemove={{fn this.remove item.id}} />
</FastEach>
{{/if}}


Expand Down
Loading