<commit_before><pre class="docs-method-signature"><code>element.prop(properties)</code></pre>

<p>Set properties, possibly nested, on the element model. This is an equivalent of the <a href="#dia.Element.prototype.attr">attr()</a> method but this time for custom data properties.</p>

<pre><code>element.prop('name/first', 'John')
element.prop('name/first')  // 'John'
element.prop({ name: { first: 'John' } })
// Nested arrays are supported too:
element.prop('mylist/0/data/0/value', 50)
element.prop({ mylist: [ { data: [ { value: 50 } ] } ] })</code></pre>

<p>To overwrite attributes, enable <i>rewrite</i> mode by adding <code>{ rewrite: true }</code> as the 3rd argument. This differs from the default behaviour which is to merge our properties.</p>

<pre><code>element.prop('custom/state/isCollapsed', true);
element.prop('custom/state', { isActive: false }, { rewrite: true });

// Output from element.toJSON();
// We can see our attributes have been overwritten
{
    "type": "standard.Rectangle",
    "position": { "x": 0, "y": 0 },
    "size": { "width": 1, "height": 1 },
    "angle": 0,
    "id": "b1c02090-e46a-4d90-a5dc-5096f1559b9f",
    "custom": {
        "state": {
            "isActive": false
        }
    },
    "attrs": {}
}
</code></pre>


<p><i>Advanced:</i> Pass <code>{ isolate: true }</code> if the property change does not affect the connected links. Typically, changing the element fill color has zero effect on attached links. By default, the element and all connected links are updated.</p>

<pre><code>element.attr(['body', 'fill'], 'red', { isolate: true });</code></pre><commit_msg>docs: fix prop typo (#1741)<commit_after><pre class="docs-method-signature"><code>element.prop(properties)</code></pre>

<p>Set properties, possibly nested, on the element model. This is an equivalent of the <a href="#dia.Element.prototype.attr">attr()</a> method but this time for custom data properties.</p>

<pre><code>element.prop('name/first', 'John')
element.prop('name/first')  // 'John'
element.prop({ name: { first: 'John' } })
// Nested arrays are supported too:
element.prop('mylist/0/data/0/value', 50)
element.prop({ mylist: [ { data: [ { value: 50 } ] } ] })</code></pre>

<p>To overwrite attributes, enable <i>rewrite</i> mode by adding <code>{ rewrite: true }</code> as the 3rd argument. This differs from the default behaviour which is to merge our properties.</p>

<pre><code>element.prop('custom/state/isCollapsed', true);
element.prop('custom/state', { isActive: false }, { rewrite: true });

// Output from element.toJSON();
// We can see our attributes have been overwritten
{
    "type": "standard.Rectangle",
    "position": { "x": 0, "y": 0 },
    "size": { "width": 1, "height": 1 },
    "angle": 0,
    "id": "b1c02090-e46a-4d90-a5dc-5096f1559b9f",
    "custom": {
        "state": {
            "isActive": false
        }
    },
    "attrs": {}
}
</code></pre>


<p><i>Advanced:</i> Pass <code>{ isolate: true }</code> if the property change does not affect the connected links. Typically, changing the element fill color has zero effect on attached links. By default, the element and all connected links are updated.</p>

<pre><code>element.prop(['attrs', 'body', 'fill'], 'red', { isolate: true });</code></pre>
{'fraction_non_alphanumeric': 0.1836859858938976, 'fraction_numerical': 0.021465808034345293, 'mean_word_length': 4.080996884735202, 'pattern_counts': {'":': 26, '<': 67, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '523734', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1026, 'n_words': 322}