Skip to content

Commit 5818cc5

Browse files
committed
update to output tag name with css selector style context from id and classList, like button#my-id.class1.class2
1 parent d477ac6 commit 5818cc5

File tree

1 file changed

+15
-4
lines changed
  • packages/@glimmer/runtime/lib/modifiers

1 file changed

+15
-4
lines changed

packages/@glimmer/runtime/lib/modifiers/on.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ export class OnModifierState {
5757
updateListener(): void {
5858
let { element, args, listener } = this;
5959

60+
let selector: string | undefined;
61+
if (DEBUG) {
62+
const el = this.element;
63+
selector =
64+
el.tagName.toLowerCase() +
65+
(el.id ? `#${el.id}` : '') +
66+
Array.from(el.classList)
67+
.map((c) => `.${c}`)
68+
.join('');
69+
}
70+
6071
let arg0 = args.positional[0];
6172
let eventName = check(
6273
arg0 ? valueForRef(arg0) : undefined,
@@ -66,7 +77,7 @@ export class OnModifierState {
6677

6778
if (DEBUG && !eventName) {
6879
throw new Error(
69-
'You must pass a valid DOM event name as the first argument to the `on` modifier'
80+
`You must pass a valid DOM event name as the first argument to the \`on\` modifier on ${selector}`
7081
);
7182
}
7283

@@ -85,13 +96,13 @@ export class OnModifierState {
8596
throw new Error(
8697
`You must pass a function as the second argument to the \`on\` modifier; you passed ${
8798
userProvidedCallback === null ? 'null' : typeof userProvidedCallback
88-
}. While rendering:\n\n${args.positional[1]?.debugLabel ?? '(unknown)'} on <${this.element.tagName.toLowerCase()}>`
99+
}. While rendering:\n\n${args.positional[1]?.debugLabel ?? '(unknown)'} on ${selector}`
89100
);
90101
}
91102

92103
if (DEBUG && args.positional.length !== 2) {
93104
throw new Error(
94-
`You can only pass two positional arguments (event name and callback) to the \`on\` modifier, but you provided ${args.positional.length}. Consider using the \`fn\` helper to provide additional arguments to the \`on\` callback.`
105+
`You can only pass two positional arguments (event name and callback) to the \`on\` modifier, but you provided ${args.positional.length}. Consider using the \`fn\` helper to provide additional arguments to the \`on\` callback on ${selector}`
95106
);
96107
}
97108

@@ -127,7 +138,7 @@ export class OnModifierState {
127138
throw new Error(
128139
`You can only \`once\`, \`passive\` or \`capture\` named arguments to the \`on\` modifier, but you provided ${Object.keys(
129140
extra
130-
).join(', ')}.`
141+
).join(', ')} on ${selector}`
131142
);
132143
}
133144
} else {

0 commit comments

Comments
 (0)