1
0
Fork 0
freesewing/markdown/dev/reference/api/attributes/setifunset/en.md

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');