clientIO / joint

A proven SVG-based JavaScript diagramming library powering exceptional UIs
https://jointjs.com
Mozilla Public License 2.0
4.51k stars 842 forks source link

refactor(dia.CellView)!: disable useCSSSelectors by default #2478

Closed kumilingus closed 5 months ago

kumilingus commented 5 months ago

Description

Use of CSS selectors within the model's attrs is now disabled by default.

The PR also moves FSA demo from archive to demo (it's not using any deprecated features).

Motivation and Context

Migration guide

Before:

joint.dia.Element.define('Rectangle', {
    attrs: {
        '.rectangle': { // CSS Selector for the <rect/> element
            fill: 'red'
        }
    }
}, {
    markup: '<rect class="rectangle"/>',
});

Now (quick fix - per shape):

joint.dia.Element.define('Rectangle', {
    attrs: {
        '.rectangle': { // CSS Selector for the <rect> element
            fill: 'red'
        }
    }
}, {
    markup: '<rect class="rectangle"/>',
    useCSSSelectors: true
});

Now (quick fix - global):

joint.config.useCSSSelectors = true;

joint.dia.Element.define('Rectangle', {
    attrs: {
        '.rectangle': { // CSS Selector for the <rect> element
            fill: 'red'
        }
    }
}, {
    markup: '<rect class="rectangle"/>'
});

Now (recommended fix):

joint.dia.Element.define('Rectangle', {
    attrs: {
        rectangle: { // JSON Selector for the <rect> element
            fill: 'red'
        }
    }
}, {
    markup: util.svg`<rect @selector="rectangle" />`,
});
zbynekstara commented 5 months ago

we can also remove line 22 (config.useCSSSelectors = false) in examples/isometric/src/index.ts