Skip to content

Commit

Permalink
Add removal of attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
enbock committed Jun 18, 2022
1 parent 43e9309 commit 7b3b0aa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
5 changes: 0 additions & 5 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@enbock/ts-jsx",
"version": "0.1.0-dev17",
"version": "0.1.0-dev18",
"description": "An simple JSX rendering based on ShadowDOMv1.",
"license": "MIT",
"author": "Endre Bock <endre@itbock.de>",
Expand Down
7 changes: 6 additions & 1 deletion src/ShadowRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,16 @@ export default class ShadowRenderer {
for (const key of Object.keys(result.props)) {
const isOnDashStyle: boolean = key.substring(0, 3) == 'on-';
if (isOnDashStyle || key.match(/^on[A-Z]/) !== null) {
const eventName:string = key.substring(isOnDashStyle ? 3 : 2).toLowerCase();
const eventName: string = key.substring(isOnDashStyle ? 3 : 2).toLowerCase();
(domNode as any)['on' + eventName] = result.props[key];
} else
domNode.setAttribute(key, result.props[key]);
}
for (let ai: number = 0; ai < domNode.attributes.length; ai++) {
const key: string = domNode.attributes.item(ai)!.name;
if (Object.hasOwn(result.props, key)) continue;
domNode.attributes.removeNamedItem(key);
}
}

private static iterateLevel(results: ShadowDomElement | ShadowDomElement[], root: HTMLElement | ShadowRoot): void {
Expand Down

0 comments on commit 7b3b0aa

Please sign in to comment.