Skip to content

Commit 5ac4ce8

Browse files
committed
design fix
1 parent aed4a5b commit 5ac4ce8

File tree

4 files changed

+58
-11
lines changed

4 files changed

+58
-11
lines changed

app/components/component-tree-item.hbs

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
<code
2525
class="component-tree-item__tag flex whitespace-no-wrap
26+
{{if @item.isClosingTag 'component-tree-item__closing'}}
27+
{{if @item.hasModifiers 'component-tree-item__has_modifier'}}
2628
{{if
2729
(or @item.isComponent @item.isModifier @item.isHtmlTag)
2830
(if

app/controllers/component-tree.js

+33-7
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ export default class ComponentTreeController extends Controller {
4848

4949
renderItems.push(item);
5050

51+
if (
52+
item.isHtmlTag &&
53+
renderNode.children.some((c) => c.type === 'modifier')
54+
) {
55+
const idx = renderNode.children.findLastIndex(
56+
(c) => c.type === 'modifier'
57+
);
58+
renderNode.children.splice(idx + 1, 0, {
59+
type: 'placeholder-closing-tag',
60+
id: renderNode.id + '-closing-tag',
61+
name: '',
62+
children: [],
63+
});
64+
}
65+
5166
renderNode.children.forEach((node) => flatten(item, node));
5267
}
5368
};
@@ -301,25 +316,34 @@ class RenderItem {
301316
}
302317

303318
get isComponent() {
304-
return this.renderNode.type === 'component' || this.renderNode.type === 'remote-element';
319+
return (
320+
this.renderNode.type === 'component' ||
321+
this.renderNode.type === 'remote-element'
322+
);
305323
}
306324

307325
get isModifier() {
308326
return this.renderNode.type === 'modifier';
309327
}
310328

311-
get isHtmlTag() {
312-
return this.renderNode.type === 'htmlTag';
329+
get hasModifiers() {
330+
return this.childItems.some((item) => item.isModifier);
313331
}
314332

315-
get isModifier() {
316-
return this.renderNode.type === 'modifier';
333+
get isLastModifier() {
334+
return (
335+
this.parentItem.childItems.findLast((item) => item.isModifier) === this
336+
);
317337
}
318338

319339
get isHtmlTag() {
320340
return this.renderNode.type === 'html-element';
321341
}
322342

343+
get isClosingTag() {
344+
return this.renderNode.type === 'placeholder-closing-tag';
345+
}
346+
323347
get name() {
324348
return this.renderNode.name;
325349
}
@@ -337,7 +361,7 @@ class RenderItem {
337361

338362
get hasInstance() {
339363
let { instance } = this.renderNode;
340-
return typeof instance === 'object' && instance !== null;
364+
return typeof instance === 'object' && instance;
341365
}
342366

343367
get instance() {
@@ -349,7 +373,7 @@ class RenderItem {
349373
}
350374

351375
get hasBounds() {
352-
return this.renderNode.bounds !== null;
376+
return this.renderNode.bounds;
353377
}
354378

355379
get isRoot() {
@@ -419,6 +443,7 @@ class RenderItem {
419443
}
420444

421445
@action showPreview() {
446+
if (this.isClosingTag) return;
422447
this.controller.previewing = this.id;
423448
}
424449

@@ -429,6 +454,7 @@ class RenderItem {
429454
}
430455

431456
@action toggleInspection() {
457+
if (this.isClosingTag) return;
432458
if (this.isPinned) {
433459
this.controller.pinned = undefined;
434460
} else {

app/styles/component_tree.scss

+13
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,19 @@
141141
color: var(--base09);
142142
}
143143

144+
.component-tree-item__has_modifier:after {
145+
content: ''!important;
146+
}
147+
148+
.component-tree-item__closing:before {
149+
content: '>';
150+
margin-left: -13px;
151+
}
152+
153+
.component-tree-item__self-closing:before {
154+
content: '/>';
155+
}
156+
144157
.component-tree-item__bracket:before {
145158
content: '<';
146159
}

ember_debug/libs/render-tree.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,18 @@ class InElementSupportProvider {
176176
const modifierState =
177177
modifier.state?.instance || modifier.state || modifier[1];
178178
const instance = modifierState?.instance || modifierState?.delegate;
179-
const name =
179+
let name =
180180
modifier.definition?.resolvedName ||
181-
modifier.manager?.getDebugName?.() ||
182181
modifierState?.debugName ||
183-
instance?.name ||
184-
'unknown-modifier';
182+
instance?.name;
183+
if (!name) {
184+
try {
185+
name = modifier.manager?.getDebugName?.();
186+
} catch (e) {
187+
// failed
188+
}
189+
name = name || 'unknown-modifier';
190+
}
185191
const args = {
186192
positional: [],
187193
named: {},

0 commit comments

Comments
 (0)