511 B
511 B
title |
---|
setIfUnset() |
Attributes attributes.setIfUnset(string key, string value)
Sets the attribute identified by key
to value value
but only if it's currently unset (undefined
).
This will never overwrite any value and thus is a safe way to set attributes
let { Path, paths } = part.shorthand();
// This will render as: class="classA"
paths.demo = new Path();
paths.demo.attributes.set('class', 'classA');
paths.demo.attributes.setIfUnset('class', 'classB');