Skip to content

Commit bc86ea7

Browse files
authored
Merge branch 'master' into patch-1
2 parents 9957c94 + 11182a2 commit bc86ea7

File tree

214 files changed

+31172
-4049
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+31172
-4049
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ module.exports = {
5252
mocha: true
5353
},
5454
parserOptions: {
55-
ecmaVersion: 6
55+
ecmaVersion: 2018
5656
},
5757
rules: {
5858
"func-names": 0,

.github/workflows/tutorial-ingestion.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ jobs:
1616
env:
1717
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1818
PULL_REQUEST_BRANCH: master
19-
PULL_REQUEST_TITLE: Octane Tutorial Updates
19+
PULL_REQUEST_TITLE: Tutorial Updates
2020
PULL_REQUEST_BODY: >
2121
This is an *[automated](https://github.com/ember-learn/guides-source/blob/super-rentals-tutorial/.github/workflows/tutorial-ingestion.yml)*
2222
pull request to let you know there are new content available for
23-
the revamped Octane tutorial!
23+
the tutorial!
2424
2525
2626
If these changes look good to you, it is recommended that you merge

.local.dic

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ runnable
145145
runtime
146146
sandboxed
147147
scp
148+
screencasting
148149
selectable
149150
serverless
150151
singularize

.percy.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 1
2+
agent:
3+
asset-discovery:
4+
network-idle-timeout: 250 # ms
5+
page-pool-size-min: 8 # pages
6+
page-pool-size-max: 15 # pages

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,10 @@ script:
2626
- npm run lint:hbs
2727
- npm run lint:js
2828
- npm run lint:md
29+
# if there's a forked PR with the `branch` set to `master`, we want to unset that for Percy
30+
# to avoid resetting the Percy projects baseline
31+
- |
32+
if [ "$TRAVIS_PULL_REQUEST_SLUG" != "ember-learn/guides-source" ] && [ "$TRAVIS_PULL_REQUEST_BRANCH" == "master" ]; then
33+
PERCY_BRANCH="fork-${TRAVIS_BUILD_NUMBER}"
34+
fi
2935
- npm test

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,12 @@ npm test
6666
### Linting and spellchecking
6767

6868
The guides are spellchecked and linted for Markdown consistency. You can test your contributions by running `npm run lint:md`. Linting and spellchecking must pass or they will fail in Travis-CI. See [CONTRIBUTING.md](CONTRIBUTING.md) for more information on linting and spellchecking.
69+
70+
71+
### Internal and external links
72+
73+
Testing of internal and external links can be performed using three commands:
74+
75+
1. `npm run test:node`. Checks all relative links for all versions of the guides and runs all ither test scripts in the `node-tests` directory, except for those located in the `node-tests/local` sub-directory;
76+
1. `npm run test:node-local`. Checks all external links in the `guides/release` folder; and
77+
1. `npm run test:node-local-exclude-api-urls`. Checks all external links except for links to the [API docs](https://api.emberjs.com).

guides/release/accessibility/page-template-considerations.md

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,76 @@ Consider this format:
1515

1616
Note that the unique page title is first. This is because it is the most important piece of information from a contextual perspective. Since a user with a screen reader can interrupt the screen reader as they wish, it introduces less fatigue when the unique page title is first, but provides the additional guidance if it is desired.
1717

18-
Until Ember provides this functionality by default, there are a few different Ember addons that will help:
18+
One simple way to add page titles is to create a `title` helper:
19+
20+
```javascript {data-filename=app/helpers/title.js}
21+
import Helper from '@ember/component/helper';
22+
23+
export default class Title extends Helper {
24+
original = document.title;
25+
26+
compute([title]) {
27+
document.title = title;
28+
}
29+
30+
willDestroy() {
31+
document.title = this.original;
32+
}
33+
}
34+
```
35+
36+
We can use this helper to set the page title at any point in any template.
37+
38+
For example, if we have a “posts” route, we can set the page title for it like so:
39+
40+
41+
```handlebars {data-filename=app/routes/posts.hbs}
42+
{{title "Posts - Site Title"}}
43+
44+
{{outlet}}
45+
```
46+
47+
Extending the example, if we have a “post” route that lives within the “posts” route, we could set its page title like so:
48+
49+
```handlebars {data-filename=app/routes/posts/post.hbs}
50+
{{title (concat @model.title " - Site Title")}}
51+
52+
<h1>{{@model.title}}</h1>
53+
```
54+
55+
This title will take effect when we enter the “post” route, and the line of code in our `willDestroy` hook will take care of restoring the former title when we return to the “posts” route.
56+
57+
This technique is a reasonable first step, but has limitations:
58+
59+
- It doesn't work when the page is rendered server-side with FastBoot.
60+
- It doesn't provide any conventions for constructing nested page titles.
61+
- It doesn't automatically apply the site title (though you can imagine how to add that).
62+
- It may not be absolutely robust if data in your app changes *a lot* (imagine a real time app).
63+
64+
When your needs become more complex, the following addons facilitate page titles in a more dynamic and maintainable way (including FastBoot support):
1965

2066
- [ember-page-title](https://github.com/adopted-ember-addons/ember-page-title)
2167
- [ember-cli-head](https://github.com/ronco/ember-cli-head)
2268
- [ember-cli-document-title](https://github.com/kimroen/ember-cli-document-title)
2369

2470
To evaluate more addons to add/manage content in the `<head>` of a page, view this category on [Ember Observer](https://emberobserver.com/categories/header-content).
2571

72+
You can test that page titles are generated correctly by asserting on the value of `document.title` in your tests:
73+
74+
```javascript {data-filename=tests/acceptance/posts-test.js}
75+
import { module, test } from 'qunit';
76+
import { visit, currentURL } from '@ember/test-helpers';
77+
import { setupApplicationTest } from 'ember-qunit';
78+
79+
module('Acceptance | posts', function(hooks) {
80+
setupApplicationTest(hooks);
81+
82+
test('visiting /posts', async function(assert) {
83+
await visit('/posts');
84+
assert.equal(document.title, 'Posts - Site Title');
85+
});
86+
});
87+
```
2688

2789
## Skip Navigation Links
2890

@@ -35,7 +97,7 @@ To read more about skip links, visit the [MDN docs](https://developer.mozilla.or
3597

3698
## Focus Management
3799

38-
No single-page application framework provides the appropriate route-level focus for assistive technology in a default manner. This is primarily due to the way `pushState` works, and the lack of an event hook for JavaScript frameworks to tell assistive technology that the page content has changed. This _also_ means that the focus is unchanged on route navigation, which in some cases means that it would be lost entirely (if the element that previously had focus is now gone).
100+
No single-page application framework provides the appropriate route-level focus for assistive technology in a default manner. This is primarily due to the way `pushState` works, and the lack of an event hook for JavaScript frameworks to tell assistive technology that the page content has changed. This *also* means that the focus is unchanged on route navigation, which in some cases means that it would be lost entirely (if the element that previously had focus is now gone).
39101

40102
Most frameworks have some mechanism for adding the missing functionality to an application. In Ember, there is an attempt to address these two specific shortcomings with [RFC 433](https://github.com/emberjs/rfcs/pull/433); in the meantime there are a few addons that exist to help provide page or view-level focus for your application. All options should be evaluated to determine which is the appropriate use case for your application:
41103

guides/release/addons-and-dependencies/index.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ datepicker that aren't specific to Ember apps.
88

99
## Addons
1010

11-
Addons are JavaScript packages that integrate with Ember. For example, [`ember-cli-sass`](https://github.com/aexmachina/ember-cli-sass)
11+
Addons are JavaScript packages that integrate with Ember. For example, [`ember-cli-sass`](https://github.com/adopted-ember-addons/ember-cli-sass)
1212
is an addon that allows you to use SASS/SCSS in your applications. You can install it using the Ember CLI with the following command:
1313

1414
```bash
1515
ember install ember-cli-sass
1616
```
1717

18-
This will modify your `package.json` (and `package-lock.json`), typically bringing in other dependencies. Some addons will also add
18+
This will modify your `package.json` (and `package-lock.json` or `yarn.lock`), typically bringing in other dependencies. Some addons will also add
1919
additional files to your projects when relevant.
2020

2121
There are many addons that cover all kinds of use cases. For more detail, as well as examples of what addons can do,
@@ -29,8 +29,8 @@ categories, and rated according to objective metrics. If you are looking for an
2929

3030
While dependencies can be managed in several ways,
3131
it's worth noting that the process can be greatly simplified for new developers by using ember-auto-import,
32-
which offers zero config imports from npm packages.
33-
It's easily installed using `ember install ember-auto-import`.
32+
which offers zero config imports from npm packages.
33+
It's built into new Ember apps by default and can be installed in older apps by using `ember install ember-auto-import`.
3434
For further usage instructions, please follow the [project README](https://github.com/ef4/ember-auto-import).
3535

3636
## Other assets
@@ -138,9 +138,9 @@ All assets located in the `public/` folder will be copied as is to the final out
138138

139139
For example, a `favicon` located at `public/images/favicon.ico` will be copied to `dist/images/favicon.ico`.
140140

141-
All third-party assets, included either manually in `vendor/` or via a package manager like npm, must be added via `import()`.
141+
All third-party assets, included either manually in `vendor/` or via a package manager like npm, must be added via `app.import()`.
142142

143-
Third-party assets that are not added via `import()` will not be present in the final build.
143+
Third-party assets that are not added via `app.import()` will not be present in the final build.
144144

145145
By default, `import`ed assets will be copied to `dist/` as they are, with the existing directory structure maintained.
146146

guides/release/applications/run-loop.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,29 +168,27 @@ which will make you a better Ember developer.
168168
You should begin a run loop when the callback fires.
169169

170170
The `Ember.run` method can be used to create a run loop.
171-
In this example, jQuery and `Ember.run` are used to handle a click event and run some Ember code.
172-
173-
This example uses the `=>` function syntax, which is a [new syntax for callback functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions)
174-
that provides a lexical `this`.
175-
If this syntax is new,
176-
think of it as a function that has the same `this` as the context it is defined in.
171+
In this example, `Ember.run` is used to handle an online
172+
event (browser gains internet access) and run some Ember code.
177173

178174
```javascript
179-
$('a').click(() => {
175+
window.addEventListener('online', () => {
180176
Ember.run(() => { // begin loop
181177
// Code that results in jobs being scheduled goes here
182178
}); // end loop, jobs are flushed and executed
183179
});
184180
```
185181

182+
183+
186184
## What happens if I forget to start a run loop in an async handler?
187185

188186
As mentioned above, you should wrap any non-Ember async callbacks in `Ember.run`.
189187
If you don't, Ember will try to approximate a beginning and end for you.
190188
Consider the following callback:
191189

192190
```javascript
193-
$('a').click(() => {
191+
window.addEventListener('online', () => {
194192
console.log('Doing things...');
195193

196194
Ember.run.schedule('actions', () => {
@@ -207,7 +205,7 @@ These automatically created run loops we call _autoruns_.
207205
Here is some pseudocode to describe what happens using the example above:
208206

209207
```javascript
210-
$('a').click(() => {
208+
window.addEventListener('online', () => {
211209
// 1. autoruns do not change the execution of arbitrary code in a callback.
212210
// This code is still run when this callback is executed and will not be
213211
// scheduled on an autorun.

guides/release/components/component-arguments-and-html-attributes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ the parts of the HTML that are different.
3939

4040
```handlebars {data-filename="app/components/avatar.hbs"}
4141
<aside>
42-
<div class="avatar" title="{{@title}}">{{@initial}}</div>
42+
<div class="avatar" title={{@title}}>{{@initial}}</div>
4343
</aside>
4444
```
4545

@@ -109,7 +109,7 @@ specified on the tag.
109109

110110
```handlebars {data-filename="app/components/avatar.hbs"}
111111
<aside ...attributes>
112-
<div class="avatar" title="{{@title}}">{{@initial}}</div>
112+
<div class="avatar" title={{@title}}>{{@initial}}</div>
113113
</aside>
114114
```
115115

guides/release/components/component-state-and-actions.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ To make this work, we will need to stop hard coding the number, and we will need
2020
to wire up the buttons.
2121

2222
```js {data-filename="app/components/counter.js"}
23-
import Component from "@glimmer/component";
24-
import { tracked } from "@glimmer/tracking";
23+
import Component from '@glimmer/component';
24+
import { tracked } from '@glimmer/tracking';
2525

2626
export default class CounterComponent extends Component {
2727
@tracked count = 0;
@@ -69,9 +69,9 @@ the component JavaScript. An action is a JavaScript method that can be used from
6969
a template.
7070

7171
```js {data-filename="app/components/counter.js" data-diff="+3,+8,+9,+10,+11,+13,+14,+15,+16"}
72-
import Component from "@glimmer/component";
73-
import { tracked } from "@glimmer/tracking";
74-
import { action } from "@ember/object";
72+
import Component from '@glimmer/component';
73+
import { tracked } from '@glimmer/tracking';
74+
import { action } from '@ember/object';
7575

7676
export default class CounterComponent extends Component {
7777
@tracked count = 0;
@@ -101,9 +101,9 @@ First, let's turn our `increment` and `decrement` methods into a single `change`
101101
method that takes the amount as a parameter.
102102

103103
```js {data-filename="app/components/counter.js" data-diff="+8,+9,+10,+11,-12,-13,-14,-15,-17,-18,-19,-20"}
104-
import Component from "@glimmer/component";
105-
import { tracked } from "@glimmer/tracking";
106-
import { action } from "@ember/object";
104+
import Component from '@glimmer/component';
105+
import { tracked } from '@glimmer/tracking';
106+
import { action } from '@ember/object';
107107

108108
export default class CounterComponent extends Component {
109109
@tracked count = 0;
@@ -171,9 +171,9 @@ Let's start with what we know already. We'll add the `multiple` tracked property
171171
and an action called `double` that doubles the `multiple`.
172172

173173
```js {data-filename="app/components/counter.js" data-diff="+7,+9,+10,+11,+12"}
174-
import Component from "@glimmer/component";
175-
import { tracked } from "@glimmer/tracking";
176-
import { action } from "@ember/object";
174+
import Component from '@glimmer/component';
175+
import { tracked } from '@glimmer/tracking';
176+
import { action } from '@ember/object';
177177

178178
export default class CounterComponent extends Component {
179179
@tracked count = 0;
@@ -208,9 +208,9 @@ To get the multiplied number into the template, we'll use a
208208
[JavaScript getter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get).
209209

210210
```js {data-filename="app/components/counter.js" data-diff="+9,+10,+11"}
211-
import Component from "@glimmer/component";
212-
import { tracked } from "@glimmer/tracking";
213-
import { action } from "@ember/object";
211+
import Component from '@glimmer/component';
212+
import { tracked } from '@glimmer/tracking';
213+
import { action } from '@ember/object';
214214

215215
export default class CounterComponent extends Component {
216216
@tracked count = 0;
@@ -291,9 +291,9 @@ let's allow it to be passed in.
291291
```
292292

293293
```js {data-filename="app/components/double-it.js"}
294-
import Component from "@glimmer/component";
295-
import { tracked } from "@glimmer/tracking";
296-
import { action } from "@ember/object";
294+
import Component from '@glimmer/component';
295+
import { tracked } from '@glimmer/tracking';
296+
import { action } from '@ember/object';
297297

298298
export default class DoubleItComponent extends Component {
299299
@tracked multiple = 1;
@@ -328,9 +328,9 @@ We refer to a component's argument from JavaScript by prefixing them with
328328
In JavaScript, we refer to it as `this.args.multiple`.
329329

330330
```js {data-filename="app/components/counter.js" data-diff="-7,-10,+11"}
331-
import Component from "@glimmer/component";
332-
import { tracked } from "@glimmer/tracking";
333-
import { action } from "@ember/object";
331+
import Component from '@glimmer/component';
332+
import { tracked } from '@glimmer/tracking';
333+
import { action } from '@ember/object';
334334

335335
export default class CounterComponent extends Component {
336336
@tracked count = 0;
@@ -372,9 +372,9 @@ previously, we could using an action passed down via arguments.
372372
```
373373

374374
```js {data-filename="app/components/counter.js" data-diff="+9,+17,+18,+19,+20"}
375-
import Component from "@glimmer/component";
376-
import { tracked } from "@glimmer/tracking";
377-
import { action } from "@ember/object";
375+
import Component from '@glimmer/component';
376+
import { tracked } from '@glimmer/tracking';
377+
import { action } from '@ember/object';
378378

379379
export default class CounterComponent extends Component {
380380
@tracked count = 0;
@@ -404,9 +404,9 @@ the multiple.
404404
```
405405

406406
```js {data-filename="app/components/double-it.js"}
407-
import Component from "@glimmer/component";
408-
import { tracked } from "@glimmer/tracking";
409-
import { action } from "@ember/object";
407+
import Component from '@glimmer/component';
408+
import { tracked } from '@glimmer/tracking';
409+
import { action } from '@ember/object';
410410

411411
export default class DoubleItComponent extends Component {
412412
@tracked multiple = 1;

guides/release/components/conditional-content.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ There are two styles of `if`, block and inline:
44

55
```handlebars
66
{{#if this.thingIsTrue}}
7-
Content for the block form of "if"
7+
Content for the block form of "if"
88
{{/if}}
99
1010
<div class={{if this.thingIsTrue "value-if-true" "value-if-false"}}>
11-
This div used the inline "if" to calculate the class to use.
11+
This div used the inline "if" to calculate the class to use.
1212
</div>
1313
```
1414

@@ -105,7 +105,7 @@ is passed in and is truthy.
105105
<aside ...attributes>
106106
<div
107107
class="avatar {{if @isActive "is-active"}}"
108-
title="{{@title}}"
108+
title={{@title}}
109109
>
110110
{{@initial}}
111111
</div>

0 commit comments

Comments
 (0)