chore: Updating final Attributes docs for v3
This commit is contained in:
parent
80a3dd1a2c
commit
e298d14b8f
12 changed files with 220 additions and 93 deletions
|
@ -1,30 +1,25 @@
|
|||
---
|
||||
title: add()
|
||||
title: Attributes.add()
|
||||
---
|
||||
|
||||
The `Attributes.add()` method adds `value` to the attribute identified by
|
||||
`key`.
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Attributes attributes.add(string key, string value)
|
||||
```
|
||||
|
||||
Adds `value` to the attribute identified by `key`.
|
||||
## Example
|
||||
|
||||
```js
|
||||
const attr = new Attributes()
|
||||
.add('class', 'classA')
|
||||
.add('class', 'classB')
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
Adding multiple values to the same key will result in them being joined together
|
||||
(with a space) when rendering.
|
||||
|
||||
```js
|
||||
let { Path, paths } = part.shorthand();
|
||||
|
||||
// This will render as: class="classA classB"
|
||||
paths.demo = new Path();
|
||||
paths.demo.attributes.add('class', 'classA');
|
||||
paths.demo.attributes.add('class', 'classB');
|
||||
|
||||
// This does the same thing:
|
||||
paths.demo = new Path()
|
||||
.attr('class', 'classA')
|
||||
.attr('class', 'classB');
|
||||
|
||||
// This also has the same result:
|
||||
paths.demo = new Path()
|
||||
.attr('class', 'classA classB');
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue