import { areStringsEquivalent } from "@fluid-example/flow-util-lib" ; import { ISegment } from "@fluidframework/merge-tree" ; import { emptyObject } from "./" ; export interface IHTMLAttributes { src ? : string ; } export function getAttrs ( segment ) { const properties = segment . properties ; return ( properties && properties . attr ) || emptyObject ; } export function syncAttrs ( element , attrs ) { for ( const name of element . getAttributeNames ( ) ) { if ( ! ( name in attrs ) ) { element . removeAttribute ( name ) ; } } for ( const [ name , value ] of Object . entries ( attrs ) ) { if ( ! areStringsEquivalent ( value , element . getAttribute ( name ) ) ) { element . setAttribute ( name , value ) ; } } }