all files / src/ get-svg-attribute-namespace.js

100% Statements 7/7
100% Branches 4/4
100% Functions 0/0
100% Lines 6/6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18              16×          
 
const ns = {
  ev: 'http://www.w3.org/2001/xml-events',
  xlink: 'http://www.w3.org/1999/xlink',
  xml: 'http://www.w3.org/XML/1998/namespace',
  xmlns: 'http://www.w3.org/2000/xmlns/'
}
 
const getSvgAttributeNamespace = (attr) => {
  if (attr.indexOf(':') === -1) return null
  var prefix = attr.split(':', 1)[0]
  return ns.hasOwnProperty(prefix)
    ? ns[prefix]
    : null
}
 
module.exports = getSvgAttributeNamespace