Skip to content

Commit 64e6ba0

Browse files
author
Tobias Brennecke
committed
#540 Only allow linking nodes which have been added before explicitly
1 parent a38dde2 commit 64e6ba0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

core/lib/pattern_graph.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,12 @@ PatternGraph.prototype = {
8585
},
8686

8787
link: function (patternFrom, patternTo) {
88-
this.add(patternFrom);
89-
this.add(patternTo);
90-
9188
let nameFrom = nodeName(patternFrom);
9289
let nameTo = nodeName(patternTo);
90+
for (let name of [nameFrom, nameTo])
91+
if (!this.patterns.has(name)) {
92+
throw new Error("Pattern not known: " + name);
93+
}
9394
this.graph.setEdge(nameFrom, nameTo);
9495
},
9596

@@ -110,7 +111,8 @@ PatternGraph.prototype = {
110111
directed: true
111112
});
112113

113-
let changedNodes = this.graph.nodes().filter(n => compileStateFilter(this.patterns, n));
114+
let nodes = this.graph.nodes();
115+
let changedNodes = nodes.filter(n => compileStateFilter(this.patterns, n));
114116
this.nodes2patterns(changedNodes).forEach(pattern => {
115117
let patternNode = nodeName(pattern);
116118
if (!compileGraph.hasNode(patternNode)) {

0 commit comments

Comments
 (0)