forked from jsx-eslint/eslint-plugin-jsx-a11y
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix]
no-noninteractive-element-interactions
: Ignore contenteditabl…
…e elements in no-noninteractive-element-interactions
- Loading branch information
1 parent
3d77c84
commit 9aa878b
Showing
5 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import expect from 'expect'; | ||
import isContentEditable from '../../../src/util/isContentEditable'; | ||
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock'; | ||
|
||
describe('isContentEditable', () => { | ||
describe('HTML5', () => { | ||
describe('content editable', () => { | ||
it('should identify HTML5 contentEditable elements', () => { | ||
const attributes = [ | ||
JSXAttributeMock('contentEditable', 'true'), | ||
]; | ||
expect(isContentEditable('some tag', attributes)) | ||
.toBe(true); | ||
}); | ||
}); | ||
|
||
describe('not content editable', () => { | ||
it('should not identify HTML5 content editable elements with null as the value', () => { | ||
const attributes = [ | ||
JSXAttributeMock('contentEditable', null), | ||
]; | ||
expect(isContentEditable('some tag', attributes)) | ||
.toBe(false); | ||
}); | ||
|
||
it('should not identify HTML5 content editable elements with undefined as the value', () => { | ||
const attributes = [ | ||
JSXAttributeMock('contentEditable', undefined), | ||
]; | ||
expect(isContentEditable('some tag', attributes)) | ||
.toBe(false); | ||
}); | ||
|
||
it('should not identify HTML5 content editable elements with true as the value', () => { | ||
const attributes = [ | ||
JSXAttributeMock('contentEditable', true), | ||
]; | ||
expect(isContentEditable('some tag', attributes)) | ||
.toBe(false); | ||
}); | ||
|
||
it('should not identify HTML5 content editable elements with "false" as the value', () => { | ||
const attributes = [ | ||
JSXAttributeMock('contentEditable', 'false'), | ||
]; | ||
expect(isContentEditable('some tag', attributes)) | ||
.toBe(false); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { getProp } from 'jsx-ast-utils'; | ||
|
||
export default function isContentEditable(tagName, attributes) { | ||
const prop = getProp(attributes, 'contentEditable'); | ||
|
||
return prop?.value?.raw === '"true"'; | ||
} |