@muban/muban
Version:
Writing components for server-rendered HTML
11 lines (10 loc) • 346 B
JavaScript
import { unref, watchEffect } from '@vue/runtime-core';
export function textBinding(target, valueAccessor) {
return watchEffect(() => {
let textValue = unref(valueAccessor);
if (textValue === null || textValue === undefined) {
textValue = '';
}
target.textContent = textValue.toString();
});
}