fix: cr, validateNear outside connection
This commit is contained in:
parent
d85bb2d16f
commit
b9dd247c75
1 changed files with 5 additions and 21 deletions
|
|
@ -736,12 +736,14 @@ func (c *compiler) validateNear(g *d2graph.Graph) {
|
|||
continue
|
||||
}
|
||||
|
||||
descendantsMap := getNearDescendants(obj)
|
||||
connectToOutside := false
|
||||
for _, edge := range g.Edges {
|
||||
if (descendantsMap[edge.Src] && !descendantsMap[edge.Dst]) ||
|
||||
(!descendantsMap[edge.Src] && descendantsMap[edge.Dst]) {
|
||||
srcNearContainer := edge.Src.OuterNearContainer()
|
||||
dstNearContainer := edge.Dst.OuterNearContainer()
|
||||
|
||||
if srcNearContainer != dstNearContainer {
|
||||
connectToOutside = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -757,24 +759,6 @@ func (c *compiler) validateNear(g *d2graph.Graph) {
|
|||
}
|
||||
}
|
||||
|
||||
func getNearDescendants(nearObj *d2graph.Object) map[*d2graph.Object]bool {
|
||||
descendantsMap := make(map[*d2graph.Object]bool)
|
||||
|
||||
var helper func(obj *d2graph.Object)
|
||||
|
||||
helper = func(obj *d2graph.Object) {
|
||||
if obj.ChildrenArray != nil {
|
||||
for _, child := range obj.ChildrenArray {
|
||||
descendantsMap[child] = true
|
||||
helper(child)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
helper(nearObj)
|
||||
return descendantsMap
|
||||
}
|
||||
|
||||
func (c *compiler) validateBoardLinks(g *d2graph.Graph) {
|
||||
for _, obj := range g.Objects {
|
||||
if obj.Attributes.Link == nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue