@dinoreic/create_element
Alternative polyfill for DOM window.createElement
Last updated a year ago by dinoreic .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @dinoreic/create_element 
SYNC missed versions from official npm registry.

DOM window.createElement - polyfill

Polyfill for window.createElement with alternative approach

If window.createElement

  • is suppoted - we use native window.createElement DOM method
  • is not supported - we register a node and a method, and we call it in interval to re-bind not binded nodes

Usage

import createElement from '@dinoreic/create_element'

Example usage for Svelte JS FW

this will make <s-tabs>...tab data</s-tabs> render tabs

import createElement from '@dinoreic/create_element'

let bindSvelteToDOM = function(name, klass) {
  createElement(name, function(node, opts) {
    # export innerHTML
    opts.innerHTML = node.innerHTML
    node.innerHTML = ''

    let element = new klass({ target: node, props: opts })

    # define global if global name given
    if (opts.global) {
      window[opts.global] = element
    }
  })
}

import SvelteTab from './svelte/tabs.svelte'
bindSvelteToDOM('s-tabs', SvelteTab)

Current Tags

  • 0.1.1                                ...           latest (a year ago)

1 Versions

  • 0.1.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |