How to use the web-namespaces.svg function in web-namespaces

To help you get started, we’ve selected a few web-namespaces 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 syntax-tree / hast-util-to-dom / src / utils.js View on Github external
export default function serializeNodeToHtmlString(node) {
  const serialized = new XMLSerializer().serializeToString(node);

  // XMLSerializer puts xmlns on “main” elements that are not in the XML
  // namespace.
  // We’d like to inspect that, but having the HTML namespace everywhere will
  // get unwieldy, so remove those.
  return serialized
    .replace(new RegExp(` xmlns="${ns.html}"`, 'g'), '')
    .replace(new RegExp(`(<(?:svg|g)) xmlns="${ns.svg}"`, 'g'), '$1');
}
github syntax-tree / hast-util-to-dom / src / index.js View on Github external
function element(node, options) {
  const { namespace, doc } = options;
  let impliedNamespace = options.impliedNamespace || namespace;
  const { tagName = impliedNamespace === ns.svg ? 'g' : 'div', properties = {}, children = [] } = node;

  if (
    (impliedNamespace === null || impliedNamespace === undefined || impliedNamespace === ns.html)
    && tagName === 'svg'
  ) {
    impliedNamespace = ns.svg;
  }

  const schema = impliedNamespace === ns.svg ? svg : html;

  const el = impliedNamespace === null || impliedNamespace === undefined
    ? doc.createElement(tagName)
    : doc.createElementNS(impliedNamespace, tagName);

  // Add HTML attributes.
  const props = Object.keys(properties);
github Prettyhtml / prettyhtml / packages / prettyhtml-hast-util-from-parse / index.js View on Github external
var fn = own.call(map, ast.nodeName) ? map[ast.nodeName] : element
  var children
  var node
  var pos

  // remove #document-fragment and update parentNode of childs
  if (ast.nodeName === 'template') {
    ast.childNodes = ast.content.childNodes
    ast.childNodes.forEach(n => {
      n.parentNode = ast
    })
    delete ast.content
  }

  if (fn === element) {
    config.schema = ast.namespaceURI === ns.svg ? svg : html
  }

  if (ast.childNodes) {
    children = nodes(ast.childNodes, config)
  }

  node = fn(ast, children, config)

  if (ast.sourceCodeLocation && config.file) {
    pos = location(node, ast.sourceCodeLocation, config)

    if (pos) {
      config.location = true
      node.position = pos
    }
  }
github syntax-tree / hast-util-to-dom / src / index.js View on Github external
function element(node, options) {
  const { namespace, doc } = options;
  let impliedNamespace = options.impliedNamespace || namespace;
  const { tagName = impliedNamespace === ns.svg ? 'g' : 'div', properties = {}, children = [] } = node;

  if (
    (impliedNamespace === null || impliedNamespace === undefined || impliedNamespace === ns.html)
    && tagName === 'svg'
  ) {
    impliedNamespace = ns.svg;
  }

  const schema = impliedNamespace === ns.svg ? svg : html;

  const el = impliedNamespace === null || impliedNamespace === undefined
    ? doc.createElement(tagName)
    : doc.createElementNS(impliedNamespace, tagName);

  // Add HTML attributes.
  const props = Object.keys(properties);
  const { length } = props;

  for (let i = 0; i < length; i += 1) {
    const key = props[i];

    const {
github syntax-tree / hast-util-to-dom / src / index.js View on Github external
function element(node, options) {
  const { namespace, doc } = options;
  let impliedNamespace = options.impliedNamespace || namespace;
  const { tagName = impliedNamespace === ns.svg ? 'g' : 'div', properties = {}, children = [] } = node;

  if (
    (impliedNamespace === null || impliedNamespace === undefined || impliedNamespace === ns.html)
    && tagName === 'svg'
  ) {
    impliedNamespace = ns.svg;
  }

  const schema = impliedNamespace === ns.svg ? svg : html;

  const el = impliedNamespace === null || impliedNamespace === undefined
    ? doc.createElement(tagName)
    : doc.createElementNS(impliedNamespace, tagName);

  // Add HTML attributes.
  const props = Object.keys(properties);
  const { length } = props;

  for (let i = 0; i < length; i += 1) {
    const key = props[i];

    const {
      attribute,
      property,
      // `mustUseAttribute`,

web-namespaces

Map of web namespaces

MIT
Latest version published 3 years ago

Package Health Score

65 / 100
Full package analysis

Popular web-namespaces functions