Freak613 / stage0

Collection of low-level DOM tools for building high performant web interfaces
MIT License
262 stars 16 forks source link

Browsers supported #33

Open benmccann opened 4 years ago

benmccann commented 4 years ago

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?

jon49 commented 4 years ago

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.

benmccann commented 4 years ago

Template tag is not supported in IE 11 either

Freak613 commented 4 years ago

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.