Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: JQuery Removal #2414

Merged
merged 58 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
69e440c
init submodule
vtalas Nov 29, 2023
1cadfc3
init submodule
vtalas Nov 29, 2023
16b1a1a
revert
vtalas Nov 29, 2023
02d478a
jQuery removal
kumilingus Nov 23, 2023
c052929
update
kumilingus Nov 23, 2023
cf35f20
update
kumilingus Nov 23, 2023
f58d74d
update
kumilingus Nov 24, 2023
458f2d5
update
kumilingus Nov 24, 2023
849862a
update
kumilingus Nov 24, 2023
b14b476
update
kumilingus Nov 25, 2023
abc458d
upadte
kumilingus Nov 27, 2023
c56960c
update
kumilingus Nov 27, 2023
da3369c
update
kumilingus Nov 27, 2023
d4170fd
simplify find
kumilingus Nov 27, 2023
1a34383
simplify core part 1
kumilingus Nov 27, 2023
96dbede
simplify core part 2
kumilingus Nov 27, 2023
27be0ca
update
kumilingus Nov 28, 2023
4fd86cf
update
kumilingus Nov 28, 2023
1c0e152
update
kumilingus Nov 30, 2023
e0e7c7c
update
kumilingus Nov 30, 2023
a213427
types
kumilingus Nov 30, 2023
0fe8cae
update
kumilingus Dec 1, 2023
9b2581b
update
kumilingus Dec 1, 2023
1f95d06
update demos
kumilingus Dec 1, 2023
fb718d3
update
kumilingus Dec 2, 2023
37b344a
update
kumilingus Dec 2, 2023
006fdac
docs demos
kumilingus Dec 2, 2023
182f696
update
kumilingus Dec 3, 2023
3db8319
update
kumilingus Dec 3, 2023
f6edb95
update tutorials
kumilingus Dec 4, 2023
7510ee2
update
kumilingus Dec 4, 2023
ee8e70d
update routing demo
kumilingus Dec 4, 2023
12c6082
update
kumilingus Dec 4, 2023
95f85f2
update
kumilingus Dec 4, 2023
c4e9400
update
kumilingus Dec 4, 2023
4b3f8b2
update
kumilingus Dec 4, 2023
d292369
update
kumilingus Dec 4, 2023
8639fdc
update
kumilingus Dec 4, 2023
126dad5
update
kumilingus Dec 4, 2023
bd447d2
update
kumilingus Dec 5, 2023
9310fa9
fix nodejs test
kumilingus Dec 5, 2023
87e08ad
update
kumilingus Dec 5, 2023
a043cbe
update
kumilingus Dec 5, 2023
250407f
update
kumilingus Dec 6, 2023
061724a
update
kumilingus Dec 6, 2023
59413fa
update
kumilingus Dec 6, 2023
2eb9471
update
kumilingus Dec 6, 2023
5b0b757
add findNode()
kumilingus Dec 7, 2023
a4a39ef
update
kumilingus Dec 7, 2023
44dee8b
update
kumilingus Dec 7, 2023
99df506
udpate
kumilingus Dec 7, 2023
842025b
udpate
kumilingus Dec 7, 2023
34ef135
update
kumilingus Dec 7, 2023
9311a7b
update
kumilingus Dec 8, 2023
9d7349e
update
kumilingus Dec 8, 2023
308a77d
Update packages/joint-core/docs/src/joint/api/dia/ElementView/prototy…
kumilingus Dec 8, 2023
0b3ee8a
Update packages/joint-core/docs/src/joint/api/dia/ElementView/prototy…
kumilingus Dec 8, 2023
3fa33f5
Update packages/joint-core/docs/src/joint/api/dia/LinkView/prototype/…
kumilingus Dec 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/joint-core/demo/shapes/src/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ joint.shapes.basic.TableView = joint.dia.ElementView.extend({

this._elements = [];
var info = this.model.prop('table/metadata');
var tableEl = this.findBySelector(info.element, this.el);
var tableEl = this.findNode(info.element);
this.tableVel = tableEl ? V(tableEl[0]) : this.vel;

this._renderFills();
Expand Down
kumilingus marked this conversation as resolved.
Show resolved Hide resolved
kumilingus marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<pre class="docs-method-signature"><code>cellView.findBySelector(selector)</code></pre>
<pre class="docs-method-signature"><code>cellView.findNode(selector)</code></pre>

<p>The method returns an array of DOM nodes matching the <code>selector</code>.</p>

Expand Down
2 changes: 1 addition & 1 deletion packages/joint-core/src/connectionPoints/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function boundaryIntersection(line, view, magnet, opt) {
var anchor = line.end;

if (typeof selector === 'string') {
node = view.findBySelector(selector)[0];
node = view.findNode(selector)[0];
} else if (selector === false) {
node = magnet;
} else if (Array.isArray(selector)) {
Expand Down
16 changes: 8 additions & 8 deletions packages/joint-core/src/dia/CellView.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,6 @@ export const CellView = View.extend({

findBySelector: function(selector, root, selectors) {

root || (root = this.el);
selectors || (selectors = this.selectors);

// These are either descendants of `this.$el` of `this.$el` itself.
// `.` is a special selector used to select the wrapping `<g>` element.
if (!selector || selector === '.') return [root];
Expand All @@ -223,6 +220,10 @@ export const CellView = View.extend({
return [];
},

findNode: function(selector) {
return this.findBySelector(selector, this.el, this.selectors);
},

notify: function(eventName) {

if (this.paper) {
Expand Down Expand Up @@ -302,7 +303,7 @@ export const CellView = View.extend({
const { el: rootNode } = this;
let node;
if (typeof el === 'string') {
[node = rootNode] = this.findBySelector(el);
[node = rootNode] = this.findNode(el);
} else {
[node = rootNode] = this.$(el);
}
Expand Down Expand Up @@ -375,7 +376,7 @@ export const CellView = View.extend({
el || (el = this.el);
const nodeSelector = el.getAttribute(`${type}-selector`);
if (nodeSelector) {
const [proxyNode] = this.findBySelector(nodeSelector);
const [proxyNode] = this.findNode(nodeSelector);
if (proxyNode) return proxyNode;
}
return el;
Expand Down Expand Up @@ -460,21 +461,20 @@ export const CellView = View.extend({

getMagnetFromLinkEnd: function(end) {

var root = this.el;
var port = end.port;
var selector = end.magnet;
var model = this.model;
var magnet;
if (port != null && model.isElement() && model.hasPort(port)) {
magnet = this.findPortNode(port, selector) || root;
magnet = this.findPortNode(port, selector) || this.el;
} else {
if (!selector) selector = end.selector;
if (!selector && port != null) {
// link end has only `id` and `port` property referencing
// a port created via the `port` attribute (not API).
selector = '[port="' + port + '"]';
}
magnet = this.findBySelector(selector, root, this.selectors)[0];
magnet = this.findNode(selector)[0];
}

return this.findProxyNode(magnet, 'magnet');
Expand Down
2 changes: 1 addition & 1 deletion packages/joint-core/src/dia/ElementView.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ export const ElementView = CellView.extend({
const proxyPortNode = this.findPortNode(port, nodeSelector);
if (proxyPortNode) return proxyPortNode;
} else {
const [proxyNode] = this.findBySelector(nodeSelector);
const [proxyNode] = this.findNode(nodeSelector);
if (proxyNode) return proxyNode;
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/joint-core/src/dia/HighlighterView.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const HighlighterView = mvc.View.extend({
findNode(cellView, nodeSelector = null) {
let el;
if (typeof nodeSelector === 'string') {
[el] = cellView.findBySelector(nodeSelector);
[el] = cellView.findNode(nodeSelector);
} else if (isPlainObject(nodeSelector)) {
const isLink = cellView.model.isLink();
const { label = null, port, selector } = nodeSelector;
Expand All @@ -67,7 +67,7 @@ export const HighlighterView = mvc.View.extend({
el = cellView.findPortNode(port, selector);
} else {
// Cell Selector
[el] = cellView.findBySelector(selector);
[el] = cellView.findNode(selector);
}
} else if (nodeSelector) {
el = V.toNode(nodeSelector);
Expand Down
2 changes: 1 addition & 1 deletion packages/joint-core/src/dia/LinkView.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ export const LinkView = CellView.extend({
var connection;
if (typeof selector === 'string') {
// Use custom connection path.
connection = this.findBySelector(selector, this.el, this.selectors)[0];
connection = this.findNode(selector)[0];
} else {
// Select connection path automatically.
var cache = this._V;
Expand Down
2 changes: 1 addition & 1 deletion packages/joint-core/src/dia/attributes/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ const attributesNS = {
if (isObject(textPath)) {
const pathSelector = textPath.selector;
if (typeof pathSelector === 'string') {
const [pathNode] = this.findBySelector(pathSelector);
const [pathNode] = this.findNode(pathSelector);
if (pathNode instanceof SVGPathElement) {
textPath = assign({ 'xlink:href': '#' + pathNode.id }, textPath);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/joint-core/src/elementTools/Control.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const Control = ToolView.extend({
this.toggleExtras(false);
return;
}
const [magnet] = relatedView.findBySelector(selector);
const [magnet] = relatedView.findNode(selector);
if (!magnet) throw new Error('Control: invalid selector.');
let padding = options.padding;
if (!isFinite(padding)) padding = 0;
Expand Down
2 changes: 1 addition & 1 deletion packages/joint-core/src/linkTools/Connect.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const Connect = Button.extend({
break;
}
case 'string': {
[magnetNode] = relatedView.findBySelector(magnet);
[magnetNode] = relatedView.findNode(magnet);
break;
}
default: {
Expand Down
2 changes: 1 addition & 1 deletion packages/joint-core/src/mvc/Dom/events.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ special.dbltap = {
if (delta < maxDelay && delta > minDelay) {
targetData.lastTouch = null;
event.type = handleObj.origType;
// let jQuery handle the triggering of "dbltap" event handlers
// let $ handle the triggering of "dbltap" event handlers
handleObj.handler.call(this, event, ...args);
} else {
targetData.lastTouch = now;
Expand Down
2 changes: 1 addition & 1 deletion packages/joint-core/src/mvc/Dom/methods.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function attr(name, value) {
attributes = { [name]: value };
}
} else if (!name) {
throw new Error('no styles provided');
throw new Error('no attributes provided');
} else {
attributes = name;
}
Expand Down
1 change: 1 addition & 0 deletions packages/joint-core/src/mvc/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export * from './ViewBase.mjs';
export * from './mvcUtils.mjs';
export { default as Data } from './Data.mjs';
export { default as $ } from './Dom/index.mjs';
export * from './Dom/Event.mjs';
2 changes: 1 addition & 1 deletion packages/joint-core/test/jointjs/cellView.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ QUnit.module('cellView', function(hooks) {
`
}].forEach(attributes => {
cell.set(attributes);
const [a] = cellView.findBySelector('a');
const [a] = cellView.findNode('a');
const bbox = V(a).getBBox({ target: cellView.el });
assert.equal(bbox.x, ax + gx);
assert.equal(bbox.y, ay + gy);
Expand Down
4 changes: 2 additions & 2 deletions packages/joint-core/test/jointjs/connectionPoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,11 @@ QUnit.module('connectionPoints', function(hooks) {
}]);
// lookup off
line = new g.Line(tp.clone(), sp.clone());
cp = connectionPointFn.call(lv1, line, rv1, rv1.findBySelector('wrapper')[0], { selector: false });
cp = connectionPointFn.call(lv1, line, rv1, rv1.findNode('wrapper')[0], { selector: false });
assert.ok(cp.round().equals(r1.getBBox().rightMiddle()));
// lookup on
line = new g.Line(tp.clone(), sp.clone());
cp = connectionPointFn.call(lv1, line, rv1, rv1.findBySelector('wrapper')[0], { selector: undefined });
cp = connectionPointFn.call(lv1, line, rv1, rv1.findNode('wrapper')[0], { selector: undefined });
assert.ok(cp.round().equals(r1.getBBox().center().offset(25, 0)));
});

Expand Down
30 changes: 15 additions & 15 deletions packages/joint-core/test/jointjs/dia/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ QUnit.module('Attributes', function() {
var el = new TestElement();
el.addTo(graph);
var view = el.findView(paper);
var text = view.findBySelector('text')[0];
var text = view.findNode('text')[0];
var tspans = text.childNodes;
assert.equal(text.getAttribute('x'), '51');
assert.equal(tspans[0].getAttribute('x'), null);
Expand Down Expand Up @@ -170,7 +170,7 @@ QUnit.module('Attributes', function() {

paper.options.embeddingMode = true;
cell.attr(['root', 'containerSelector'], 'body');
var body = cellView.findBySelector('body')[0];
var body = cellView.findNode('body')[0];

var highlightSpy = sinon.spy();
var unhighlightSpy = sinon.spy();
Expand Down Expand Up @@ -201,7 +201,7 @@ QUnit.module('Attributes', function() {
QUnit.test('highlighting, magnet, validation', function(assert) {

cell.attr(['root', 'magnetSelector'], 'body');
var body = cellView.findBySelector('body')[0];
var body = cellView.findNode('body')[0];

var highlightSpy = sinon.spy();
var unhighlightSpy = sinon.spy();
Expand Down Expand Up @@ -242,7 +242,7 @@ QUnit.module('Attributes', function() {
QUnit.test('highlighting, magnet, validation', function(assert) {

cell.attr(['root', 'highlighterSelector'], 'body');
var body = cellView.findBySelector('body')[0];
var body = cellView.findNode('body')[0];

var highlightSpy = sinon.spy();
var unhighlightSpy = sinon.spy();
Expand Down Expand Up @@ -528,7 +528,7 @@ QUnit.module('Attributes', function() {
}
});

var bodyNode = cellView.findBySelector('body')[0];
var bodyNode = cellView.findNode('body')[0];
var markerAttribute = bodyNode.getAttribute('marker-start');
var match = idRegex.exec(markerAttribute);
assert.ok(match);
Expand Down Expand Up @@ -561,7 +561,7 @@ QUnit.module('Attributes', function() {
}
});

var bodyNode = cellView.findBySelector('body')[0];
var bodyNode = cellView.findNode('body')[0];
var markerAttribute = bodyNode.getAttribute('marker-start');
var match = idRegex.exec(markerAttribute);
assert.ok(match);
Expand All @@ -588,7 +588,7 @@ QUnit.module('Attributes', function() {
}
});

var bodyNode = cellView.findBySelector('body')[0];
var bodyNode = cellView.findNode('body')[0];
var markerAttribute = bodyNode.getAttribute('marker-end');
var match = idRegex.exec(markerAttribute);
assert.ok(match);
Expand All @@ -615,7 +615,7 @@ QUnit.module('Attributes', function() {
}
});

var bodyNode = cellView.findBySelector('body')[0];
var bodyNode = cellView.findNode('body')[0];
var markerAttribute = bodyNode.getAttribute('marker-end');
var match = idRegex.exec(markerAttribute);
assert.ok(match);
Expand Down Expand Up @@ -657,7 +657,7 @@ QUnit.module('Attributes', function() {
}
});

var bodyNode = cellView.findBySelector('body')[0];
var bodyNode = cellView.findNode('body')[0];
var markerAttribute = bodyNode.getAttribute('marker-end');
var match = idRegex.exec(markerAttribute);
assert.ok(match);
Expand Down Expand Up @@ -700,7 +700,7 @@ QUnit.module('Attributes', function() {
}
});

var bodyNode = cellView.findBySelector('body')[0];
var bodyNode = cellView.findNode('body')[0];
var markerAttribute = bodyNode.getAttribute('marker-end');
var match = idRegex.exec(markerAttribute);
assert.ok(match);
Expand Down Expand Up @@ -743,7 +743,7 @@ QUnit.module('Attributes', function() {
}
});

var bodyNode = cellView.findBySelector('body')[0];
var bodyNode = cellView.findNode('body')[0];
var markerAttribute = bodyNode.getAttribute('marker-end');
var match = idRegex.exec(markerAttribute);
assert.ok(match);
Expand Down Expand Up @@ -788,7 +788,7 @@ QUnit.module('Attributes', function() {
}
});

var bodyNode = cellView.findBySelector('body')[0];
var bodyNode = cellView.findNode('body')[0];
var markerAttribute = bodyNode.getAttribute('marker-end');
var match = idRegex.exec(markerAttribute);
assert.ok(match);
Expand Down Expand Up @@ -823,7 +823,7 @@ QUnit.module('Attributes', function() {
}
});

var bodyNode = cellView.findBySelector('body')[0];
var bodyNode = cellView.findNode('body')[0];
var markerAttribute = bodyNode.getAttribute('marker-mid');
var match = idRegex.exec(markerAttribute);
assert.ok(match);
Expand Down Expand Up @@ -851,7 +851,7 @@ QUnit.module('Attributes', function() {
}
});

var bodyNode = cellView.findBySelector('body')[0];
var bodyNode = cellView.findNode('body')[0];
var markerAttribute = bodyNode.getAttribute('fill');
var match = idRegex.exec(markerAttribute);
assert.ok(match);
Expand Down Expand Up @@ -880,7 +880,7 @@ QUnit.module('Attributes', function() {
}
});

var bodyNode = cellView.findBySelector('body')[0];
var bodyNode = cellView.findNode('body')[0];
var markerAttribute = bodyNode.getAttribute('stroke');
var match = idRegex.exec(markerAttribute);
assert.ok(match);
Expand Down
4 changes: 2 additions & 2 deletions packages/joint-core/test/jointjs/dia/elementTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ QUnit.module('elementTools', function(hooks) {
});
// magnet defined as a function
var magnetSpy = sinon.spy(function(view) {
return view.findBySelector('body')[0];
return view.findNode('body')[0];
});
paper.options.defaultLink = defaultLinkSpy;
var connect = new joint.elementTools.Connect({ magnet: magnetSpy });
Expand All @@ -200,7 +200,7 @@ QUnit.module('elementTools', function(hooks) {
assert.deepEqual(newLink.source(), { id: element.id, magnet: 'body' });
assert.ok(magnetSpy.calledOn(connect));
// magnet defined as an SVGElement
connect.options.magnet = elementView.findBySelector('label')[0];
connect.options.magnet = elementView.findNode('label')[0];
evt = {};
connect.dragstart(evt);
connect.drag(evt);
Expand Down
4 changes: 2 additions & 2 deletions packages/joint-core/test/jointjs/dia/linkTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ QUnit.module('linkTools', function(hooks) {
});
// magnet defined as a function
var magnetSpy = sinon.spy(function(view) {
return view.findBySelector('line')[0];
return view.findNode('line')[0];
});
paper.options.defaultLink = defaultLinkSpy;
var connect = new joint.linkTools.Connect({ magnet: magnetSpy });
Expand All @@ -216,7 +216,7 @@ QUnit.module('linkTools', function(hooks) {
assert.deepEqual(newLink.source(), { id: link.id, magnet: 'line' });
assert.ok(magnetSpy.calledOn(connect));
// magnet defined as an SVGElement
connect.options.magnet = linkView.findBySelector('wrapper')[0];
connect.options.magnet = linkView.findNode('wrapper')[0];
evt = {};
connect.dragstart(evt);
connect.drag(evt);
Expand Down
6 changes: 3 additions & 3 deletions packages/joint-core/test/jointjs/elementView.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ QUnit.module('elementView', function(hooks) {

elementView.model.resize(100, 100).translate(100, 100).rotate(90);

var rectInside = elementView.findBySelector('rectInside')[0];
var rectInside = elementView.findNode('rectInside')[0];
assert.checkBboxApproximately(1, elementView.getNodeBBox(rectInside), {
x: 177,
y: 121,
Expand All @@ -259,7 +259,7 @@ QUnit.module('elementView', function(hooks) {

assert.equal(V.matrixToTransformString(elementView.getNodeMatrix(rectInside)), 'matrix(1,0,0,1,0,0)');

var rectOutside = elementView.findBySelector('rectOutside')[0];
var rectOutside = elementView.findNode('rectOutside')[0];
assert.checkBboxApproximately(1, elementView.getNodeBBox(rectOutside), {
x: 121,
y: 113,
Expand All @@ -269,7 +269,7 @@ QUnit.module('elementView', function(hooks) {

assert.equal(V.matrixToTransformString(elementView.getNodeMatrix(rectOutside)), 'matrix(1,0,0,1,0,0)');

var circle = elementView.findBySelector('circle')[0];
var circle = elementView.findNode('circle')[0];
assert.checkBboxApproximately(1, elementView.getNodeBBox(circle), {
x: 182,
y: 106,
Expand Down
Loading