How to use the snabbdom/modules/dataset.default function in snabbdom

To help you get started, we’ve selected a few snabbdom 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 marktext / marktext / src / editor / parser / StateRender.js View on Github external
import virtualize from 'snabbdom-virtualize/strings'
import { CLASS_OR_ID, IMAGE_EXT_REG } from '../config'
import { conflict, isLengthEven, union, isEven, getUniqueId, loadImage, getImageSrc } from '../utils'
import { insertAfter, operateClassName } from '../utils/domManipulate'
import { tokenizer } from './parse'
import { validEmoji } from '../emojis'

const snabbdom = require('snabbdom')
const patch = snabbdom.init([ // Init patch function with chosen modules
  require('snabbdom/modules/class').default, // makes it easy to toggle classes
  require('snabbdom/modules/attributes').default,
  require('snabbdom/modules/props').default, // for setting properties on DOM elements
  require('snabbdom/modules/dataset').default
])
const h = require('snabbdom/h').default // helper function for creating vnodes
const toHTML = require('snabbdom-to-html')
const toVNode = require('snabbdom/tovnode').default

const PRE_BLOCK_HASH = {
  'code': `.${CLASS_OR_ID['AG_CODE_BLOCK']}`,
  'html': `.${CLASS_OR_ID['AG_HTML_BLOCK']}`,
  'frontmatter': `.${CLASS_OR_ID['AG_FRONT_MATTER']}`
}

class StateRender {
  constructor (eventCenter) {
    this.eventCenter = eventCenter
    this.loadImageMap = new Map()
    this.container = null
github marktext / muya / lib / render / snabbdom.js View on Github external
// import virtualize from 'snabbdom-virtualize/strings'
const snabbdom = require('snabbdom')

export const patch = snabbdom.init([ // Init patch function with chosen modules
  require('snabbdom/modules/class').default, // makes it easy to toggle classes
  require('snabbdom/modules/attributes').default,
  require('snabbdom/modules/style').default, // handles styling on elements with support for animations
  require('snabbdom/modules/props').default, // for setting properties on DOM elements
  require('snabbdom/modules/dataset').default,
  require('snabbdom/modules/eventlisteners').default // attaches event listeners
])
export const h = require('snabbdom/h').default // helper function for creating vnodes
export const toHTML = require('snabbdom-to-html') // helper function for convert vnode to HTML string
export const toVNode = require('snabbdom/tovnode').default // helper function for convert DOM to vnode
export const htmlToVNode = html => { // helper function for convert html to vnode
  const wrapper = document.createElement('div')
  wrapper.innerHTML = html
  return toVNode(wrapper).children
}
github skatejs / skatejs / packages / element-snabbdom / src / __tests__ / index.ts View on Github external
import { wait } from '@skatejs/bore';
import define from '@skatejs/define';
import Element, { h } from '..';

const Test = define(
  class extends Element {
    static modules = [
      require('snabbdom/modules/attributes').default,
      require('snabbdom/modules/eventlisteners').default,
      require('snabbdom/modules/class').default,
      require('snabbdom/modules/props').default,
      require('snabbdom/modules/style').default,
      require('snabbdom/modules/dataset').default
    ];
    static props = { name: String };
    name: string = 'World';
    render() {
      return h('span', `Hello, ${this.name}!`);
    }
  }
);

function testContent(text) {
  return `<span>Hello, ${text}!</span>`;
}

test('renders', async () =&gt; {
  const el = new Test();
  await wait();
github mbasso / asm-dom / benchmarks / src / index.js View on Github external
import '../../src/cpp/';
import Perf from './Perf';

console.log('Preparing...');

const snabbdom = {
  h: require('snabbdom/h').default,
  patch: require('snabbdom').init([
    require('snabbdom/modules/class').default,
    require('snabbdom/modules/dataset').default,
    require('snabbdom/modules/props').default,
    require('snabbdom/modules/style').default,
    require('snabbdom/modules/eventlisteners').default,
    require('snabbdom/modules/attributes').default,
  ]),
};
window.snabbdom = snabbdom;

const config = {};

import('../compiled/wasm/app.wasm')
.then((wasm) => {
  config.wasmBinary = new Uint8Array(wasm);
  return import('../compiled/wasm/app.js').then(factory => {
    const asmDom = factory(config);
    delete asmDom.then;
github flintinatux / puddles / lib / init.js View on Github external
const init = actions =>
  snabbdom.init([
    actions.route ? link(actions) : {},
    require('snabbdom/modules/attributes').default,
    require('snabbdom/modules/class').default,
    require('snabbdom/modules/dataset').default,
    require('snabbdom/modules/eventlisteners').default,
    require('snabbdom/modules/props').default,
    require('snabbdom/modules/style').default
  ])
github jayrbolton / snabbdom-statechart-components / index.js View on Github external
var mitt = require('mitt')
var harel = require('harel')
var snabbdom = require('snabbdom')
var patch = snabbdom.init([
  require('snabbdom/modules/props').default,
  require('snabbdom/modules/style').default,
  require('snabbdom/modules/class').default,
  require('snabbdom/modules/eventlisteners').default,
  require('snabbdom/modules/dataset').default,
  require('snabbdom/modules/attributes').default
])

module.exports = Component

var id = 0
function Component (options) {
  var component = {
    id: id++,
    handlers: {},
    tracing: options.trace,
    view: options.view,
    emitter: mitt(),
    on: function () {
      this.emitter.on.apply(this.emitter, arguments)
      return this
github prism-rb / prism / build / prism.js View on Github external
},{}],13:[function(require,module,exports){
var snabbdom = require('snabbdom');
var patch = snabbdom.init([
  require('snabbdom/modules/class').default,
  require('snabbdom/modules/attributes').default,
  require('snabbdom/modules/props').default,
  require('snabbdom/modules/style').default,
  require('snabbdom/modules/eventlisteners').default,
  require('snabbdom/modules/dataset').default
]);
snabbdom_h = require('snabbdom/h').default;

function stringifyEvent(e) {
  const obj = {};
  for (let k in e) {
    obj[k] = e[k];
  }
  return JSON.stringify(obj, (k, v) => {
    if (v instanceof Node) return 'Node';
    if (v instanceof Window) return 'Window';
    return v;
  }, ' ');
}

window.stringifyEvent = stringifyEvent;
github prism-rb / prism / src / prism.js View on Github external
var snabbdom = require('snabbdom');
var patch = snabbdom.init([
  require('snabbdom/modules/class').default,
  require('snabbdom/modules/attributes').default,
  require('snabbdom/modules/props').default,
  require('snabbdom/modules/style').default,
  require('snabbdom/modules/eventlisteners').default,
  require('snabbdom/modules/dataset').default
]);
snabbdom_h = require('snabbdom/h').default;

function stringifyEvent(e) {
  const obj = {};
  for (let k in e) {
    obj[k] = e[k];
  }
  return JSON.stringify(obj, (k, v) => {
    if (v instanceof Node) return 'Node';
    if (v instanceof Window) return 'Window';
    return v;
  }, ' ');
}

window.stringifyEvent = stringifyEvent;