mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 10:42:44 +00:00
Remove unnecessary compatibility layer (#66)
This commit is contained in:
@@ -2226,14 +2226,7 @@ const globalExport = {};
|
|||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Backward Compatibility for extending the functionality via prototype.
|
globalThis.LGraph = LiteGraph.LGraph = LGraph;
|
||||||
function LegacyLGraph(...args) {
|
|
||||||
return new LGraph(...args);
|
|
||||||
}
|
|
||||||
LegacyLGraph.prototype = LGraph.prototype;
|
|
||||||
|
|
||||||
globalThis.LGraph = LGraph;
|
|
||||||
globalThis.LegacyLGraph = LiteGraph.LGraph = LegacyLGraph;
|
|
||||||
|
|
||||||
//this is the class in charge of storing link information
|
//this is the class in charge of storing link information
|
||||||
function LLink(id, type, origin_id, origin_slot, target_id, target_slot) {
|
function LLink(id, type, origin_id, origin_slot, target_id, target_slot) {
|
||||||
@@ -14455,8 +14448,7 @@ LGraphNode.prototype.executeAction = function(action)
|
|||||||
})(globalExport)
|
})(globalExport)
|
||||||
|
|
||||||
export const LiteGraph = globalExport.LiteGraph;
|
export const LiteGraph = globalExport.LiteGraph;
|
||||||
export const LGraphES6 = globalExport.LGraph;
|
export const LGraph = globalExport.LGraph;
|
||||||
export const LGraph = globalExport.LegacyLGraph;
|
|
||||||
export const LLink = globalExport.LLink;
|
export const LLink = globalExport.LLink;
|
||||||
export const LGraphNode = globalExport.LGraphNode;
|
export const LGraphNode = globalExport.LGraphNode;
|
||||||
export const LGraphGroup = globalExport.LGraphGroup;
|
export const LGraphGroup = globalExport.LGraphGroup;
|
||||||
|
|||||||
@@ -1,39 +1,24 @@
|
|||||||
import {
|
import {
|
||||||
LGraphES6 as LGraph,
|
LGraph,
|
||||||
LGraph as LegacyLGraph,
|
|
||||||
LiteGraph,
|
LiteGraph,
|
||||||
} from "../dist/litegraph.es.js";
|
} from "../dist/litegraph.es.js";
|
||||||
|
|
||||||
describe("LegacyLGraph Compatibility Layer", () => {
|
describe("LegacyLGraph Compatibility Layer", () => {
|
||||||
test("LegacyLGraph can be instantiated", () => {
|
test("LGraph can be instantiated", () => {
|
||||||
const graph = new LegacyLGraph({extra: "TestGraph"});
|
const graph = new LGraph({extra: "TestGraph"});
|
||||||
expect(graph).toBeInstanceOf(LGraph);
|
expect(graph).toBeInstanceOf(LGraph);
|
||||||
expect(graph).toBeInstanceOf(LegacyLGraph);
|
|
||||||
expect(graph.extra).toBe("TestGraph");
|
expect(graph.extra).toBe("TestGraph");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("LegacyLGraph can be extended via prototype", () => {
|
test("LGraph can be extended via prototype", () => {
|
||||||
LegacyLGraph.prototype.newMethod = function () {
|
const graph = new LGraph();
|
||||||
|
LGraph.prototype.newMethod = function () {
|
||||||
return "New method added via prototype";
|
return "New method added via prototype";
|
||||||
};
|
};
|
||||||
|
|
||||||
const graph = new LegacyLGraph();
|
|
||||||
expect(graph.newMethod()).toBe("New method added via prototype");
|
expect(graph.newMethod()).toBe("New method added via prototype");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Extensions to LegacyLGraph affect LGraph instances", () => {
|
|
||||||
LegacyLGraph.prototype.anotherMethod = function () {
|
|
||||||
return "Another method";
|
|
||||||
};
|
|
||||||
|
|
||||||
const legacyGraph = new LegacyLGraph();
|
|
||||||
const normalGraph = new LGraph();
|
|
||||||
|
|
||||||
expect(legacyGraph.anotherMethod()).toBe("Another method");
|
|
||||||
expect(normalGraph.anotherMethod()).toBe("Another method");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("LegacyLGraph is correctly assigned to LiteGraph", () => {
|
test("LegacyLGraph is correctly assigned to LiteGraph", () => {
|
||||||
expect(LiteGraph.LGraph).toBe(LegacyLGraph);
|
expect(LiteGraph.LGraph).toBe(LGraph);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user