🦒 Replace contenteditable const

pull/4291/head
himynameisdave 5 years ago
parent bab3520bd7
commit 56cf9b864b
No known key found for this signature in database
GPG Key ID: CF799D9C390BE444

@ -7,7 +7,6 @@ import {
has_contenteditable_attr,
is_name_contenteditable,
get_contenteditable_attr,
CONTENTEDITABLE_ATTR,
CONTENTEDITABLE_BINDINGS,
} from './contenteditable';
import Element from '../nodes/Element';
@ -43,7 +42,7 @@ describe('contenteditable', () => {
assert.equal(is_contenteditable(node), false);
});
it('returns true if node is not input or textarea AND it is contenteditable', () => {
const attr = { name: CONTENTEDITABLE_ATTR } as Attribute;
const attr = { name: 'contenteditable' } as Attribute;
const node = { name: 'a', attributes: [attr] } as Element;
assert.equal(is_contenteditable(node), true);
});
@ -66,7 +65,7 @@ describe('contenteditable', () => {
describe('is_attr_contenteditable', () => {
it('returns true if attribute is contenteditable', () => {
const attr = { name: CONTENTEDITABLE_ATTR } as Attribute;
const attr = { name: 'contenteditable' } as Attribute;
assert.equal(is_attr_contenteditable(attr), true);
});
it('returns false if attribute is not contenteditable', () => {
@ -78,7 +77,7 @@ describe('contenteditable', () => {
describe('has_contenteditable_attr', () => {
it('returns true if attribute is contenteditable', () => {
const attr = { name: CONTENTEDITABLE_ATTR } as Attribute;
const attr = { name: 'contenteditable' } as Attribute;
const node = { attributes: [attr] } as Element;
assert.equal(has_contenteditable_attr(node), true);
});
@ -100,7 +99,7 @@ describe('contenteditable', () => {
describe('get_contenteditable_attr', () => {
it('returns the contenteditable Attribute if it exists', () => {
const attr = { name: CONTENTEDITABLE_ATTR } as Attribute;
const attr = { name: 'contenteditable' } as Attribute;
const node = { name: 'div', attributes: [attr] } as Element;
assert.equal(get_contenteditable_attr(node), attr);
});

@ -1,10 +1,7 @@
// Utilities for managing contenteditable nodes
// Utilities for managing contenteditable nodes
import Attribute from '../nodes/Attribute';
import Element from '../nodes/Element';
export const CONTENTEDITABLE_ATTR = 'contenteditable';
export const CONTENTEDITABLE_BINDINGS = [
'textContent',
'innerHTML',
@ -24,7 +21,7 @@ export function is_input_or_textarea(node: Element): boolean {
* @param {Attribute} attribute A node.attribute
*/
export function is_attr_contenteditable(attribute: Attribute): boolean {
return attribute.name === CONTENTEDITABLE_ATTR;
return attribute.name === 'contenteditable';
}
/**

Loading…
Cancel
Save