reappear works

This commit is contained in:
Alexander Wang 2023-06-25 18:59:53 -07:00
parent 48bb6df3fe
commit 6749115ce2
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
3 changed files with 94 additions and 2 deletions

View file

@ -250,7 +250,6 @@ func (c *compiler) compileMap(obj *d2graph.Object, m *d2ir.Map) {
}
func (c *compiler) compileField(obj *d2graph.Object, f *d2ir.Field) {
println("\033[1;31m--- DEBUG:", "=======================", "\033[m")
keyword := strings.ToLower(f.Name)
_, isStyleReserved := d2graph.StyleKeywords[keyword]
if isStyleReserved {

View file

@ -156,6 +156,13 @@ func (c *compiler) compileField(dst *Map, kp *d2ast.KeyPath, refctx *RefContext)
return
}
if f.Primary() != nil {
// null only applies if it's the appearance
if _, ok := f.Primary().Value.(*d2ast.Null); ok {
f.Primary_ = nil
}
}
if refctx.Key.Primary.Unbox() != nil {
f.Primary_ = &Scalar{
parent: f,

View file

@ -104,7 +104,93 @@
"zIndex": 0
},
"edges": null,
"objects": null
"objects": [
{
"id": "a",
"id_val": "a",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/shape.d2,1:0:1-1:1:2",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/shape.d2,1:0:1-1:1:2",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/shape.d2,2:0:3-2:1:4",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/shape.d2,2:0:3-2:1:4",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/shape.d2,3:0:11-3:1:12",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile2/nulls/reappear/shape.d2,3:0:11-3:1:12",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "a"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
},
"err": null
}