Skip to content

Commit af0dfbb

Browse files
committed
double @ should allow for upercase events
1 parent bf01cfa commit af0dfbb

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ use if="[[expression]]" an a template element to show it conditionally
8383
## Event Code Bindings
8484

8585
with for example @click="[[this.aa(event)]]" you could create a event binding wich could run any javascript code inside of the brackets.
86-
use @@ if you do not want to replace - with uppercase
86+
use @@ if you want to replace - with uppercase in events
8787

8888

8989
### Binding extensions

src/BaseCustomWebComponent.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ export class BaseCustomWebComponentNoAttachedTemplate extends HTMLElement {
113113
if (a.name == "@touch:contextmenu")
114114
addTouchFriendlyContextMenu(node, this[a.value].bind(this));
115115
else {
116-
const sNm = a.name.substr(1);
116+
let sNm = a.name.substr(1);
117+
if (sNm[0] === '@') {
118+
sNm = sNm.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
119+
}
117120
let nm = sNm.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
118121
if (node[nm] instanceof TypedEvent) {
119122
(<TypedEvent<any>>node[nm]).on(this[a.value].bind(this));
@@ -222,9 +225,9 @@ export class BaseCustomWebComponentNoAttachedTemplate extends HTMLElement {
222225
} else if (a.name[0] === '@') { //todo remove events on repeat refresh
223226
let nm;
224227
if (a.name[1] === '@')
225-
nm = a.name.substring(2, a.name.length);
228+
nm = a.name.substring(2, a.name.length).replace(/-([a-z])/g, (g) => g[1].toUpperCase());
226229
else
227-
nm = a.name.substring(1, a.name.length).replace(/-([a-z])/g, (g) => g[1].toUpperCase());
230+
nm = a.name.substring(1, a.name.length);
228231
const value = a.value.substring(2, a.value.length - 2).replaceAll('&amp;', '&');
229232
if (a.name == "@touch:contextmenu")
230233
addTouchFriendlyContextMenu(node, (e) => this._bindingRunEval(value, repeatBindingItems, e, host, context));

0 commit comments

Comments
 (0)