stage0 icon indicating copy to clipboard operation
stage0 copied to clipboard

Browsers supported

Open benmccann opened this issue 4 years ago • 3 comments

Hi, I'm wondering what browsers are supported. The README said that polyfills are not required, but also says that template strings are used, which are not supported in IE. So does that mean this library doesn't support IE? Are there other APIs used that would affect browser support?

benmccann avatar May 07 '20 03:05 benmccann

You can look in the code and see what APIs are used and look them up. Template strings are only used if you want to use them. I just create a template tag and work off of it. Let me know what you find.

jon49 avatar Jun 02 '20 01:06 jon49

Template tag is not supported in IE 11 either

benmccann avatar Jun 07 '20 04:06 benmccann

Yes, that's true, template tags are not supported in IE and would require a polyfill. It was used simply for convenience of writing multiline strings and library in current state would be fine with input of just any single string.

I'll update readme on browser support, and will think how to get it.

Given small library footprint, desired functionality can be achieved with:

export function h(str) {
  const template = str
    .replace(/>\n+/g, '>')
    .replace(/\s+</g, '<')
    .replace(/>\s+/g, '>')
    .replace(/\n\s+/g, '<!-- -->')
  compilerTemplate.innerHTML = template
  const content = compilerTemplate.content.firstChild
  compile(content)
  return content
}

However, I have to check other parts, as some low-level DOM API can also be unsupported in IE.

Freak613 avatar Jun 07 '20 04:06 Freak613