How to use the incremental-dom.elementOpen function in incremental-dom

To help you get started, we’ve selected a few incremental-dom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spectjs / spect / html.js View on Github external
// fragment (direct vdom)
    if (!tag) return children.forEach(render)

    let el

    // <ul is="">
    if (is) {
      function create() { return document.createElement(tag, { is }) }
      el = elementOpen(create, key, staticProps, ...props)
      children.forEach(render)
      elementClose(create)
    }

    // if (!children) el = elementVoid(tag, key, staticProps, ...props)
    else {
      el = elementOpen(tag, key, staticProps, ...props)
      children.forEach(render)
      elementClose(tag)
    }

    // plan aspects init
    if (use) (new $(el)).use(...use)

    // run provided effects
    for (let effect in effects) {
      $(el)[effect](effects[effect])
    }
  }
</ul>
github spectjs / spect / src / min.js View on Github external
// fragment (direct vdom)
      if (!tag) return children.forEach(render)

      let el

      // <ul is="">
      if (is) {
        function create() { return document.createElement(tag, { is }) }
        el = elementOpen(create, key, staticProps, ...props)
        children.forEach(render)
        elementClose(create)
      }

      // if (!children) el = elementVoid(tag, key, staticProps, ...props)
      else {
        el = elementOpen(tag, key, staticProps, ...props)
        children.forEach(render)
        elementClose(tag)
      }

      // plan aspects init
      if (use) (new $(el)).use(...use)

      // run provided effects
      for (let effect in effects) {
        $(el)[effect](effects[effect])
      }
    }
</ul>
github spectjs / spect / src / html-idom.js View on Github external
}

  if (typeof arg === 'object' && !arg[_vnode]) return text(arg.toString())

  // objects create elements
  let { tag, key, props, staticProps, children } = arg

  // fragment (direct vdom)
  if (!tag) return children && children.forEach(render)

  let el
  if (!children || !children.length) {
    el = elementVoid(tag, key, staticProps, ...props)
  }
  else {
    el = elementOpen(tag, key, staticProps, ...props)
    children.forEach(render)
    elementClose(tag)
  }
}
github joshthecoder / idom-redux-todomvc-app / components / TodoItem.js View on Github external
function ReadView({todo, startEditingTodo}) {
  function onDoubleClick() {
    startEditingTodo(todo.id);

    // TODO: Better way of access the real DOM element of a component?
    // Here we want to focus the input field and set the curor to the end
    const input = document.querySelector('.edit');
    input.focus();
    input.setSelectionRange(input.value.length, input.value.length);
  }

  elementOpen('div', null, ['class', 'view']);
    elementVoid('input', null, ['class', 'toggle', 'type', 'checkbox']);
    elementOpen('label', null, null, 'ondblclick', onDoubleClick);
      text(todo.text);
    elementClose('label');
    elementVoid('button', null, ['class', 'destroy']);
  elementClose('div');
}
github joshthecoder / idom-redux-todomvc-app / components / TodoItem.js View on Github external
function ReadView({todo, startEditingTodo}) {
  function onDoubleClick() {
    startEditingTodo(todo.id);

    // TODO: Better way of access the real DOM element of a component?
    // Here we want to focus the input field and set the curor to the end
    const input = document.querySelector('.edit');
    input.focus();
    input.setSelectionRange(input.value.length, input.value.length);
  }

  elementOpen('div', null, ['class', 'view']);
    elementVoid('input', null, ['class', 'toggle', 'type', 'checkbox']);
    elementOpen('label', null, null, 'ondblclick', onDoubleClick);
      text(todo.text);
    elementClose('label');
    elementVoid('button', null, ['class', 'destroy']);
  elementClose('div');
}
github joshthecoder / idom-redux-todomvc-app / components / Header.js View on Github external
export default function({addTodo}) {
  elementOpen('header', null, null, 'class', 'header');
    elementOpen('h1');
      text('todos');
    elementClose('h1');
    TodoTextInput({newTodo: true});
  elementClose('header');
};
github joshthecoder / idom-redux-todomvc-app / components / TodoTextInput.js View on Github external
export default function({editing, newTodo, text, onSave}) {
  function handleBlur(e) {
    if (!newTodo) {
      onSave(e.target.value);
    }
  }

  elementOpen(
    'input', null,
    ['type', 'text'],
    'class', classnames({
      edit: editing,
      'new-todo': newTodo
    }),
    'value', text,
    'onblur', handleBlur
  );
  elementClose('input');
};
github joshthecoder / idom-redux-todomvc-app / components / MainSection.js View on Github external
export default function({todos, user, actions}) {
  elementOpen('section', null, ['class', 'main']);
    elementOpen('ul', null, ['class', 'todo-list']);
      todos.map(todo => {
        TodoItem({todo, editing: user.editing === todo.id, ...actions});
      });
    elementClose('ul');
  elementClose('section');
};
github joshthecoder / idom-redux-todomvc-app / components / Header.js View on Github external
export default function({addTodo}) {
  elementOpen('header', null, null, 'class', 'header');
    elementOpen('h1');
      text('todos');
    elementClose('h1');
    TodoTextInput({newTodo: true});
  elementClose('header');
};
github joshthecoder / idom-redux-todomvc-app / components / MainSection.js View on Github external
export default function({todos, user, actions}) {
  elementOpen('section', null, ['class', 'main']);
    elementOpen('ul', null, ['class', 'todo-list']);
      todos.map(todo => {
        TodoItem({todo, editing: user.editing === todo.id, ...actions});
      });
    elementClose('ul');
  elementClose('section');
};