mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-09-24 23:01:18 +08:00
fix(curriculum): update specific assert methods in reusable mega navbar workshop (#59880)
This commit is contained in:
+1
-1
@@ -34,7 +34,7 @@ The reason why `className` is used here instead of `class` is because `class` is
|
||||
You should return a `nav` element.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('nav'));
|
||||
assert.exists(document.querySelector('nav'));
|
||||
```
|
||||
|
||||
Your `nav` element should have a `className` attribute with the value `navbar`.
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ Create a `ul` element inside the `nav` element. Inside that `ul` element, create
|
||||
You should create a `ul` element inside your `nav` element.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('nav ul'));
|
||||
assert.exists(document.querySelector('nav ul'));
|
||||
```
|
||||
|
||||
You should create three `li` elements inside your `ul` element.
|
||||
|
||||
+3
-3
@@ -14,9 +14,9 @@ Give all three `li` elements the `className` `nav-item`.
|
||||
Your three `li` elements should have the `className` `nav-item`.
|
||||
|
||||
```js
|
||||
assert(document.querySelectorAll('ul li')[0]?.classList.contains('nav-item'));
|
||||
assert(document.querySelectorAll('ul li')[1]?.classList.contains('nav-item'));
|
||||
assert(document.querySelectorAll('ul li')[2]?.classList.contains('nav-item'));
|
||||
assert.isTrue(document.querySelectorAll('ul li')[0]?.classList.contains('nav-item'));
|
||||
assert.isTrue(document.querySelectorAll('ul li')[1]?.classList.contains('nav-item'));
|
||||
assert.isTrue(document.querySelectorAll('ul li')[2]?.classList.contains('nav-item'));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ Create an anchor element inside the first `li` element. Give the `a` element an
|
||||
You should create an `a` element inside the first list item.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('li a'));
|
||||
assert.exists(document.querySelector('li a'));
|
||||
```
|
||||
|
||||
Your `a` element should have its `href` attribute set to `#`.
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ Create another `a` element inside the second `li` element. Give it an `href` att
|
||||
You should create an `a` element inside the second list item.
|
||||
|
||||
```js
|
||||
assert.equal(document.querySelectorAll('li a').length, 2);
|
||||
assert.lengthOf(document.querySelectorAll('li a'), 2);
|
||||
```
|
||||
|
||||
Your `a` element should have its `href` attribute set to `#`.
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ The `aria-expanded` attribute will communicate to screen reader users that the b
|
||||
You should create a `button` tag inside the second list item.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('li button'));
|
||||
assert.exists(document.querySelector('li button'));
|
||||
```
|
||||
|
||||
Your button should have an `aria-expanded` attribute set to `false`.
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ Still inside the third `li` element, create a `ul` element for the popup. Give i
|
||||
You should create a `ul` element inside your third `li` element.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('li ul'));
|
||||
assert.exists(document.querySelector('li ul'));
|
||||
```
|
||||
|
||||
You should set the `className` attribute of your `ul` element to `sub-menu`.
|
||||
|
||||
Reference in New Issue
Block a user