Skip to content

Commit 65dfc04

Browse files
authored
fix(curriculum): update tests, remove self-closing (freeCodeCamp#55547)
1 parent c5bfb62 commit 65dfc04

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

curriculum/challenges/english/14-responsive-web-design-22/learn-responsive-web-design-by-building-a-piano/612e83ec2eca1e370f830511.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,53 @@ dashedName: step-8
77

88
# --description--
99

10-
Add a `link` element within your `head` element. For that `link` element, set the `rel` attribute to `stylesheet` and the `href` to `./styles.css`.
10+
Add a `link` element inside your `head` element. Give it a `rel` attribute set to `stylesheet` and an `href` attribute set to `styles.css`.
1111

1212
# --hints--
1313

1414
Your code should have a `link` element.
1515

1616
```js
17-
assert.match(code, /<link/)
17+
assert.isNotNull(document.querySelector('link'));
1818
```
1919

2020
You should not change your existing `head` tags. Make sure you did not delete the closing tag.
2121

2222
```js
23-
const heads = document.querySelectorAll('head');
24-
assert.equal(heads?.length, 1);
23+
const headElements = document.querySelectorAll('head');
24+
assert.strictEqual(headElements?.length, 1);
2525
```
2626
27-
You should have one self-closing `link` element.
27+
You should have one `link` element.
2828
2929
```js
30-
assert(document.querySelectorAll('link').length === 1);
30+
assert.strictEqual(document.querySelectorAll('link')?.length, 1);
3131
```
3232
33-
Your `link` element should be within your `head` element.
33+
Your `link` element should be inside your `head` element.
3434
3535
```js
36-
assert.exists(document.querySelector('head > link'));
36+
const headContentRegex = /(?<=<head\s*>)(?:.|\s*)*?(?=<\/head\s*>)/;
37+
const headElementContent = code.match(headContentRegex);
38+
39+
const headElement = document.createElement("head");
40+
headElement.innerHTML = headElementContent;
41+
assert.isNotNull(headElement.querySelector('link'));
3742
```
3843
3944
Your `link` element should have a `rel` attribute with the value `stylesheet`.
4045
4146
```js
42-
const link_element = document.querySelector('link');
43-
const rel = link_element.getAttribute("rel");
44-
assert.equal(rel, "stylesheet");
47+
const linkElement = document.querySelector('link');
48+
const rel = linkElement?.getAttribute("rel");
49+
assert.strictEqual(rel, "stylesheet");
4550
```
4651
4752
Your `link` element should have an `href` attribute with the value `styles.css`.
4853
4954
```js
50-
const link = document.querySelector('link');
51-
assert.equal(link.dataset.href, "styles.css");
55+
const linkElement = document.querySelector('link');
56+
assert.strictEqual(linkElement?.dataset.href, "styles.css");
5257
```
5358
5459
# --seed--

0 commit comments

Comments
 (0)