🍂 Make Element work with bind:innerText

pull/4291/head
himynameisdave 7 years ago committed by himynameisdave
parent aa6445c610
commit 3d9b93926d
No known key found for this signature in database
GPG Key ID: CF799D9C390BE444

@ -1,7 +1,9 @@
import { is_void } from '../../../utils/names'; import { is_void } from '../../../utils/names';
import isContenteditable, { isBindingContenteditable } from '../../utils/contenteditable';
import { get_attribute_value, get_class_attribute_value } from './shared/get_attribute_value'; import { get_attribute_value, get_class_attribute_value } from './shared/get_attribute_value';
import { boolean_attributes } from './shared/boolean_attributes'; import { boolean_attributes } from './shared/boolean_attributes';
import Renderer, { RenderOptions } from '../Renderer'; import Renderer, { RenderOptions } from '../Renderer';
import Binding from '../../nodes/Binding';
import Element from '../../nodes/Element'; import Element from '../../nodes/Element';
import { x } from 'code-red'; import { x } from 'code-red';
import Expression from '../../nodes/shared/Expression'; import Expression from '../../nodes/shared/Expression';
@ -14,11 +16,7 @@ export default function(node: Element, renderer: Renderer, options: RenderOption
// awkward special case // awkward special case
let node_contents; let node_contents;
const contenteditable = ( const contenteditable = isContenteditable(node);
node.name !== 'textarea' &&
node.name !== 'input' &&
node.attributes.some((attribute) => attribute.name === 'contenteditable')
);
renderer.add_string(`<${node.name}`); renderer.add_string(`<${node.name}`);
@ -95,7 +93,7 @@ export default function(node: Element, renderer: Renderer, options: RenderOption
} }
} }
node.bindings.forEach(binding => { node.bindings.forEach((binding: Binding) => {
const { name, expression } = binding; const { name, expression } = binding;
if (binding.is_readonly) { if (binding.is_readonly) {
@ -104,7 +102,7 @@ export default function(node: Element, renderer: Renderer, options: RenderOption
if (name === 'group') { if (name === 'group') {
// TODO server-render group bindings // TODO server-render group bindings
} else if (contenteditable && (name === 'textContent' || name === 'innerHTML')) { } else if (contenteditable && isBindingContenteditable(binding)) {
node_contents = expression.node; node_contents = expression.node;
// TODO where was this used? // TODO where was this used?

Loading…
Cancel
Save