Example #1
0
function svg(tagName, properties, children) {
  if (!children && isChildren(properties)) {
    children = properties;
    properties = {};
  }

  properties = properties || {};

  // set namespace for svg
  properties.namespace = SVG_NAMESPACE;

  var attributes = properties.attributes || (properties.attributes = {});

  for (var key in properties) {
    if (!properties.hasOwnProperty(key)) {
      continue;
    }

    var namespace = SVGAttributeNamespace(key);

    if (namespace === undefined) { // not a svg attribute
      continue;
    }

    var value = properties[key];

    if (typeof value !== 'string' &&
      typeof value !== 'number' &&
      typeof value !== 'boolean'
    ) {
      continue;
    }

    if (namespace !== null) { // namespaced attribute
      properties[key] = attributeHook(namespace, value);
      continue;
    }

    attributes[key] = value
    properties[key] = undefined
  }

  return h(tagName, properties, children);
}
Example #2
0
 return function(result) {
   result[key] = attributeHook(ns, value);
 };