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

Setting translate through direct access does not work #3800

Merged
merged 6 commits into from
Feb 8, 2024
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
2 changes: 2 additions & 0 deletions compat/src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ function handleDomVNode(vnode) {
// value will be used as the file name and the file will be called
// "true" upon downloading it.
value = '';
} else if (lowerCased === 'translate' && value === 'no') {
value = false;
} else if (lowerCased === 'ondoubleclick') {
i = 'ondblclick';
} else if (
Expand Down
10 changes: 10 additions & 0 deletions compat/test/browser/render.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,16 @@ describe('compat render', () => {
expect(updateSpy).to.not.be.calledOnce;
});

it('should support the translate attribute w/ yes as a string', () => {
render(<b translate="yes">Bold</b>, scratch);
expect(scratch.innerHTML).to.equal('<b translate="yes">Bold</b>');
});

it('should support the translate attribute w/ no as a string', () => {
render(<b translate="no">Bold</b>, scratch);
expect(scratch.innerHTML).to.equal('<b translate="no">Bold</b>');
});

it('should support false aria-* attributes', () => {
render(<div aria-checked={false} />, scratch);
expect(scratch.firstChild.getAttribute('aria-checked')).to.equal('false');
Expand Down
2 changes: 1 addition & 1 deletion src/jsx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2419,7 +2419,7 @@ export namespace JSXInternal {
| undefined
| SignalLike<boolean | undefined>;
results?: number | undefined | SignalLike<number | undefined>;
translate?: 'yes' | 'no' | undefined | SignalLike<'yes' | 'no' | undefined>;
translate?: boolean | undefined | SignalLike<boolean | undefined>;

// RDFa Attributes
about?: string | undefined | SignalLike<string | undefined>;
Expand Down
10 changes: 10 additions & 0 deletions test/browser/render.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ describe('render()', () => {
expect(scratch.firstChild).to.have.property('nodeName', 'X-BAR');
});

it('should support the translate attribute w/ false as a boolean', () => {
render(<b translate={false}>Bold</b>, scratch);
expect(scratch.innerHTML).to.equal('<b translate="no">Bold</b>');
});

it('should support the translate attribute w/ true as a boolean', () => {
render(<b translate>Bold</b>, scratch);
expect(scratch.innerHTML).to.equal('<b translate="yes">Bold</b>');
});

it('should support the form attribute', () => {
render(
<div>
Expand Down
Loading