function quoteAndroidSpaces()

in js/src/android-serialize.ts [148:167]


function quoteAndroidSpaces(el: Element, isRoot: boolean) {
  // @ts-expect-error No, TS, it _is_ iterable.
  for (const node of el.childNodes as Iterable<ChildNode>) {
    if (node instanceof Element) {
      quoteAndroidSpaces(node, false)
    } else if (node instanceof Text && node.data.includes('  ')) {
      node.data = `"${node.data}"`
    }
  }
  if (isRoot) {
    const first = el.firstChild
    const last = el.lastChild
    if (first instanceof Text) {
      if (/^[ @?]/.test(first.data)) first.data = `"${first.data}"`
    }
    if (last instanceof Text && last !== first) {
      if (last.data.endsWith(' ')) last.data = `"${last.data}"`
    }
  }
}