Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement/use getRootNode for this references in JSX DSD #131

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/jsx-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

const jsxRegex = /\.(jsx)$/;

// TODO same hack as definitions

Check warning on line 12 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO same hack as definitions'

Check warning on line 12 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO same hack as definitions'

Check warning on line 12 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO same hack as definitions'

Check warning on line 12 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO same hack as definitions'

Check warning on line 12 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO same hack as definitions'

Check warning on line 12 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO same hack as definitions'

Check warning on line 12 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO same hack as definitions'

Check warning on line 12 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO same hack as definitions'

Check warning on line 12 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO same hack as definitions'

Check warning on line 12 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO same hack as definitions'

Check warning on line 12 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO same hack as definitions'

Check warning on line 12 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO same hack as definitions'

Check warning on line 12 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO same hack as definitions'

Check warning on line 12 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO same hack as definitions'

Check warning on line 12 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO same hack as definitions'

Check warning on line 12 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO same hack as definitions'
// https://github.com/ProjectEvergreen/wcc/discussions/74
let string;

// TODO move to a util

Check warning on line 16 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO move to a util'

Check warning on line 16 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO move to a util'

Check warning on line 16 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO move to a util'

Check warning on line 16 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO move to a util'

Check warning on line 16 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO move to a util'

Check warning on line 16 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO move to a util'

Check warning on line 16 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO move to a util'

Check warning on line 16 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO move to a util'

Check warning on line 16 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO move to a util'

Check warning on line 16 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO move to a util'

Check warning on line 16 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO move to a util'

Check warning on line 16 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO move to a util'

Check warning on line 16 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO move to a util'

Check warning on line 16 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO move to a util'

Check warning on line 16 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO move to a util'

Check warning on line 16 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO move to a util'
// https://github.com/ProjectEvergreen/wcc/discussions/74
function getParse(html) {
return html.indexOf('<html>') >= 0 || html.indexOf('<body>') >= 0 || html.indexOf('<head>') >= 0
Expand All @@ -38,6 +38,7 @@
};
}

// replace all instances of __this__ marker with relative reference to the custom element parent node
function applyDomDepthSubstitutions(tree, currentDepth = 1, hasShadowRoot = false) {
try {
for (const node of tree.childNodes) {
Expand All @@ -50,9 +51,9 @@
const { value } = attrs[attr];

if (value.indexOf('__this__.') >= 0) {
const root = hasShadowRoot ? 'parentNode.host' : 'parentElement';
const root = hasShadowRoot ? '.getRootNode().host' : `${'.parentElement'.repeat(currentDepth)}`;

node.attrs[attr].value = value.replace(/__this__/g, `this${'.parentElement'.repeat(currentDepth - 1)}.${root}`);
node.attrs[attr].value = value.replace(/__this__/g, `this${root}`);
}
}
}
Expand Down Expand Up @@ -100,7 +101,7 @@
}

// onclick={() => this.deleteUser(user.id)}
// TODO onclick={(e) => { this.deleteUser(user.id) }}

Check warning on line 104 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO onclick={(e) => {...'

Check warning on line 104 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO onclick={(e) => {...'

Check warning on line 104 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO onclick={(e) => {...'

Check warning on line 104 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO onclick={(e) => {...'

Check warning on line 104 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO onclick={(e) => {...'

Check warning on line 104 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO onclick={(e) => {...'

Check warning on line 104 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO onclick={(e) => {...'

Check warning on line 104 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO onclick={(e) => {...'

Check warning on line 104 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO onclick={(e) => {...'

Check warning on line 104 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO onclick={(e) => {...'

Check warning on line 104 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO onclick={(e) => {...'

Check warning on line 104 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO onclick={(e) => {...'

Check warning on line 104 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO onclick={(e) => {...'

Check warning on line 104 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO onclick={(e) => {...'

Check warning on line 104 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO onclick={(e) => {...'

Check warning on line 104 in src/jsx-loader.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO onclick={(e) => {...'
// TODO onclick={(e) => { this.deleteUser(user.id) && this.logAction(user.id) }}
// https://github.com/ProjectEvergreen/wcc/issues/88
if (expression.type === 'ArrowFunctionExpression') {
Expand Down
2 changes: 1 addition & 1 deletion test/cases/jsx-shadow-dom/jsx-shadow-dom.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('Run WCC For ', function() {
const wrapper = new JSDOM(heading.innerHTML);
const button = wrapper.window.document.querySelector('button');

expect(button.getAttribute('onclick')).to.be.equal('this.parentElement.parentNode.host.sayHello()');
expect(button.getAttribute('onclick')).to.be.equal('this.getRootNode().host.sayHello()');
});
});

Expand Down
Loading