Skip to content

Commit c5bfb62

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

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

curriculum/challenges/english/14-responsive-web-design-22/learn-html-forms-by-building-a-registration-form/62cc5b1779e4d313466f73c5.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,59 @@ dashedName: step-5
77

88
# --description--
99

10-
Nest a self-closing `link` element within the `head` element. Give it a `rel` attribute with value of `stylesheet` and an `href` attribute with a value of `styles.css`.
10+
Nest a `link` element within the `head` element. Give it a `rel` attribute with a value of `stylesheet` and an `href` attribute with a value of `styles.css`.
1111

1212
# --hints--
1313

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

1616
```js
17-
assert.exists(document.querySelector('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
2323
const heads = document.querySelectorAll('head');
24-
assert.equal(heads?.length, 1);
24+
assert.strictEqual(heads?.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 a void element, it should not have an end tag `</link>`.
3434
3535
```js
36-
assert.exists(document.querySelector('head > link'));
36+
assert.notMatch(code, /<\/link>/);
37+
```
38+
39+
Your `link` element should be inside your `head` element.
40+
41+
```js
42+
const headContentRegex = /(?<=<head\s*>)(?:.|\s*)*?(?=<\/head\s*>)/;
43+
const headElementContent = code.match(headContentRegex);
44+
45+
const headElement = document.createElement("head");
46+
headElement.innerHTML = headElementContent;
47+
assert.isNotNull(headElement.querySelector('link'));
3748
```
3849
3950
Your `link` element should have a `rel` attribute with the value `stylesheet`.
4051
4152
```js
42-
const link_element = document.querySelector('link');
43-
const rel = link_element.getAttribute("rel");
44-
assert.equal(rel, "stylesheet");
53+
const linkElement = document.querySelector('link');
54+
const rel = linkElement?.getAttribute("rel");
55+
assert.strictEqual(rel, "stylesheet");
4556
```
4657
4758
Your `link` element should have an `href` attribute with the value `styles.css`.
4859
4960
```js
5061
const link = document.querySelector('link');
51-
assert.equal(link.dataset.href, "styles.css");
62+
assert.strictEqual(link?.dataset.href, "styles.css");
5263
```
5364
5465
# --seed--

0 commit comments

Comments
 (0)