react-svg
Advanced tools
Comparing version 2.1.21 to 2.1.22
@@ -0,3 +1,8 @@ | ||
import { configure } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
configure({ adapter: new Adapter() }); | ||
if (!global.SVGSVGElement && global.HTMLUnknownElement) { | ||
global.SVGSVGElement = global.HTMLUnknownElement | ||
global.SVGSVGElement = global.HTMLUnknownElement; | ||
} |
1423
dist/ReactSVG.js
@@ -10,43 +10,66 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
root["ReactSVG"] = factory(root["React"], root["ReactDOMServer"]); | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE_7__, __WEBPACK_EXTERNAL_MODULE_8__) { | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_7__) { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ if(installedModules[moduleId]) { | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ return __webpack_require__(__webpack_require__.s = 0); | ||
/******/ }) | ||
@@ -56,841 +79,833 @@ /************************************************************************/ | ||
/* 0 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _react = __webpack_require__(7); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _react = __webpack_require__(1); | ||
var _propTypes = __webpack_require__(4); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _propTypes = __webpack_require__(2); | ||
var _server = __webpack_require__(8); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _server2 = _interopRequireDefault(_server); | ||
var _server = __webpack_require__(7); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _server2 = _interopRequireDefault(_server); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
// See: https://github.com/webpack/react-starter/issues/37 | ||
var isBrowser = typeof window !== 'undefined'; | ||
var SVGInjector = isBrowser ? __webpack_require__(6) : undefined; | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var ReactSVG = function (_Component) { | ||
_inherits(ReactSVG, _Component); | ||
// See: https://github.com/webpack/react-starter/issues/37 | ||
var isBrowser = typeof window !== 'undefined'; | ||
var SVGInjector = isBrowser ? __webpack_require__(8) : undefined; | ||
function ReactSVG() { | ||
var _ref; | ||
var ReactSVG = function (_Component) { | ||
_inherits(ReactSVG, _Component); | ||
var _temp, _this, _ret; | ||
function ReactSVG() { | ||
var _ref; | ||
_classCallCheck(this, ReactSVG); | ||
var _temp, _this, _ret; | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_classCallCheck(this, ReactSVG); | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ReactSVG.__proto__ || Object.getPrototypeOf(ReactSVG)).call.apply(_ref, [this].concat(args))), _this), _this.refCallback = function (container) { | ||
if (!container) { | ||
_this.removeSVG(); | ||
return; | ||
} | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this.container = container; | ||
_this.renderSVG(); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ReactSVG.__proto__ || Object.getPrototypeOf(ReactSVG)).call.apply(_ref, [this].concat(args))), _this), _this.refCallback = function (container) { | ||
if (!container) { | ||
_this.removeSVG(); | ||
return; | ||
} | ||
_createClass(ReactSVG, [{ | ||
key: 'renderSVG', | ||
value: function renderSVG() { | ||
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props; | ||
var each = props.callback, | ||
className = props.className, | ||
evalScripts = props.evalScripts, | ||
path = props.path, | ||
style = props.style; | ||
_this.container = container; | ||
_this.renderSVG(); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
_createClass(ReactSVG, [{ | ||
key: 'renderSVG', | ||
value: function renderSVG() { | ||
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props; | ||
var each = props.callback, | ||
className = props.className, | ||
evalScripts = props.evalScripts, | ||
path = props.path, | ||
style = props.style; | ||
var div = document.createElement('div'); | ||
div.innerHTML = _server2.default.renderToStaticMarkup(_react2.default.createElement( | ||
'div', | ||
null, | ||
_react2.default.createElement('div', { | ||
className: className, | ||
'data-src': path, | ||
style: style | ||
}) | ||
)); | ||
var wrapper = this.container.appendChild(div.firstChild); | ||
var div = document.createElement('div'); | ||
div.innerHTML = _server2.default.renderToStaticMarkup(_react2.default.createElement( | ||
'div', | ||
null, | ||
_react2.default.createElement('div', { className: className, 'data-src': path, style: style }) | ||
)); | ||
SVGInjector(wrapper.firstChild, { | ||
evalScripts: evalScripts, | ||
each: each | ||
}); | ||
} | ||
}, { | ||
key: 'removeSVG', | ||
value: function removeSVG() { | ||
this.container.removeChild(this.container.firstChild); | ||
} | ||
}, { | ||
key: 'componentWillReceiveProps', | ||
value: function componentWillReceiveProps(nextProps) { | ||
this.removeSVG(); | ||
this.renderSVG(nextProps); | ||
} | ||
}, { | ||
key: 'shouldComponentUpdate', | ||
value: function shouldComponentUpdate() { | ||
return false; | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return _react2.default.createElement('div', { ref: this.refCallback }); | ||
} | ||
}]); | ||
var wrapper = this.container.appendChild(div.firstChild); | ||
return ReactSVG; | ||
}(_react.Component); | ||
SVGInjector(wrapper.firstChild, { | ||
evalScripts: evalScripts, | ||
each: each | ||
}); | ||
} | ||
}, { | ||
key: 'removeSVG', | ||
value: function removeSVG() { | ||
this.container.removeChild(this.container.firstChild); | ||
} | ||
}, { | ||
key: 'componentWillReceiveProps', | ||
value: function componentWillReceiveProps(nextProps) { | ||
this.removeSVG(); | ||
this.renderSVG(nextProps); | ||
} | ||
}, { | ||
key: 'shouldComponentUpdate', | ||
value: function shouldComponentUpdate() { | ||
return false; | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return _react2.default.createElement('div', { ref: this.refCallback }); | ||
} | ||
}]); | ||
ReactSVG.defaultProps = { | ||
callback: function callback() {}, | ||
className: '', | ||
evalScripts: 'once', | ||
style: {} | ||
}; | ||
ReactSVG.propTypes = { | ||
callback: _propTypes2.default.func, | ||
className: _propTypes2.default.string, | ||
evalScripts: _propTypes2.default.oneOf(['always', 'once', 'never']), | ||
path: _propTypes2.default.string.isRequired, | ||
style: _propTypes2.default.object | ||
}; | ||
exports.default = ReactSVG; | ||
module.exports = exports['default']; | ||
return ReactSVG; | ||
}(_react.Component); | ||
/***/ }, | ||
ReactSVG.defaultProps = { | ||
callback: function callback() {}, | ||
className: '', | ||
evalScripts: 'once', | ||
style: {} | ||
}; | ||
ReactSVG.propTypes = { | ||
callback: _propTypes2.default.func, | ||
className: _propTypes2.default.string, | ||
evalScripts: _propTypes2.default.oneOf(['always', 'once', 'never']), | ||
path: _propTypes2.default.string.isRequired, | ||
style: _propTypes2.default.object | ||
}; | ||
exports.default = ReactSVG; | ||
module.exports = exports['default']; | ||
/***/ }), | ||
/* 1 */ | ||
/***/ function(module, exports) { | ||
/***/ (function(module, exports) { | ||
"use strict"; | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_1__; | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* | ||
*/ | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
function makeEmptyFunction(arg) { | ||
return function () { | ||
return arg; | ||
}; | ||
} | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
/** | ||
* This function accepts and discards inputs; it has no side effects. This is | ||
* primarily useful idiomatically for overridable function endpoints which | ||
* always need to be callable, since JS lacks a null-call idiom ala Cocoa. | ||
*/ | ||
var emptyFunction = function emptyFunction() {}; | ||
if (false) { | ||
var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && | ||
Symbol.for && | ||
Symbol.for('react.element')) || | ||
0xeac7; | ||
emptyFunction.thatReturns = makeEmptyFunction; | ||
emptyFunction.thatReturnsFalse = makeEmptyFunction(false); | ||
emptyFunction.thatReturnsTrue = makeEmptyFunction(true); | ||
emptyFunction.thatReturnsNull = makeEmptyFunction(null); | ||
emptyFunction.thatReturnsThis = function () { | ||
return this; | ||
}; | ||
emptyFunction.thatReturnsArgument = function (arg) { | ||
return arg; | ||
}; | ||
var isValidElement = function(object) { | ||
return typeof object === 'object' && | ||
object !== null && | ||
object.$$typeof === REACT_ELEMENT_TYPE; | ||
}; | ||
module.exports = emptyFunction; | ||
// By explicitly using `prop-types` you are opting into new development behavior. | ||
// http://fb.me/prop-types-in-prod | ||
var throwOnDirectAccess = true; | ||
module.exports = require('./factoryWithTypeCheckers')(isValidElement, throwOnDirectAccess); | ||
} else { | ||
// By explicitly using `prop-types` you are opting into new production behavior. | ||
// http://fb.me/prop-types-in-prod | ||
module.exports = __webpack_require__(3)(); | ||
} | ||
/***/ }, | ||
/* 2 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
*/ | ||
/***/ }), | ||
/* 3 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
"use strict"; | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
/** | ||
* Use invariant() to assert state which your program assumes to be true. | ||
* | ||
* Provide sprintf-style format (only %s is supported) and arguments | ||
* to provide information about what broke and what you were | ||
* expecting. | ||
* | ||
* The invariant message will be stripped in production, but the invariant | ||
* will remain to ensure logic does not differ in production. | ||
*/ | ||
var validateFormat = function validateFormat(format) {}; | ||
if (false) { | ||
validateFormat = function validateFormat(format) { | ||
if (format === undefined) { | ||
throw new Error('invariant requires an error message argument'); | ||
} | ||
}; | ||
} | ||
var emptyFunction = __webpack_require__(4); | ||
var invariant = __webpack_require__(5); | ||
var ReactPropTypesSecret = __webpack_require__(6); | ||
function invariant(condition, format, a, b, c, d, e, f) { | ||
validateFormat(format); | ||
module.exports = function() { | ||
function shim(props, propName, componentName, location, propFullName, secret) { | ||
if (secret === ReactPropTypesSecret) { | ||
// It is still safe when called from React. | ||
return; | ||
} | ||
invariant( | ||
false, | ||
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + | ||
'Use PropTypes.checkPropTypes() to call them. ' + | ||
'Read more at http://fb.me/use-check-prop-types' | ||
); | ||
}; | ||
shim.isRequired = shim; | ||
function getShim() { | ||
return shim; | ||
}; | ||
// Important! | ||
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. | ||
var ReactPropTypes = { | ||
array: shim, | ||
bool: shim, | ||
func: shim, | ||
number: shim, | ||
object: shim, | ||
string: shim, | ||
symbol: shim, | ||
if (!condition) { | ||
var error; | ||
if (format === undefined) { | ||
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); | ||
} else { | ||
var args = [a, b, c, d, e, f]; | ||
var argIndex = 0; | ||
error = new Error(format.replace(/%s/g, function () { | ||
return args[argIndex++]; | ||
})); | ||
error.name = 'Invariant Violation'; | ||
} | ||
any: shim, | ||
arrayOf: getShim, | ||
element: shim, | ||
instanceOf: getShim, | ||
node: shim, | ||
objectOf: getShim, | ||
oneOf: getShim, | ||
oneOfType: getShim, | ||
shape: getShim, | ||
exact: getShim | ||
}; | ||
error.framesToPop = 1; // we don't care about invariant's own frame | ||
throw error; | ||
} | ||
} | ||
ReactPropTypes.checkPropTypes = emptyFunction; | ||
ReactPropTypes.PropTypes = ReactPropTypes; | ||
module.exports = invariant; | ||
return ReactPropTypes; | ||
}; | ||
/***/ }, | ||
/* 3 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/** | ||
* Copyright 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
/***/ }), | ||
/* 4 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
"use strict"; | ||
var emptyFunction = __webpack_require__(1); | ||
var invariant = __webpack_require__(2); | ||
var ReactPropTypesSecret = __webpack_require__(5); | ||
module.exports = function() { | ||
function shim(props, propName, componentName, location, propFullName, secret) { | ||
if (secret === ReactPropTypesSecret) { | ||
// It is still safe when called from React. | ||
return; | ||
} | ||
invariant( | ||
false, | ||
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + | ||
'Use PropTypes.checkPropTypes() to call them. ' + | ||
'Read more at http://fb.me/use-check-prop-types' | ||
); | ||
}; | ||
shim.isRequired = shim; | ||
function getShim() { | ||
return shim; | ||
}; | ||
// Important! | ||
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. | ||
var ReactPropTypes = { | ||
array: shim, | ||
bool: shim, | ||
func: shim, | ||
number: shim, | ||
object: shim, | ||
string: shim, | ||
symbol: shim, | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* | ||
*/ | ||
any: shim, | ||
arrayOf: getShim, | ||
element: shim, | ||
instanceOf: getShim, | ||
node: shim, | ||
objectOf: getShim, | ||
oneOf: getShim, | ||
oneOfType: getShim, | ||
shape: getShim | ||
}; | ||
function makeEmptyFunction(arg) { | ||
return function () { | ||
return arg; | ||
}; | ||
} | ||
ReactPropTypes.checkPropTypes = emptyFunction; | ||
ReactPropTypes.PropTypes = ReactPropTypes; | ||
/** | ||
* This function accepts and discards inputs; it has no side effects. This is | ||
* primarily useful idiomatically for overridable function endpoints which | ||
* always need to be callable, since JS lacks a null-call idiom ala Cocoa. | ||
*/ | ||
var emptyFunction = function emptyFunction() {}; | ||
return ReactPropTypes; | ||
}; | ||
emptyFunction.thatReturns = makeEmptyFunction; | ||
emptyFunction.thatReturnsFalse = makeEmptyFunction(false); | ||
emptyFunction.thatReturnsTrue = makeEmptyFunction(true); | ||
emptyFunction.thatReturnsNull = makeEmptyFunction(null); | ||
emptyFunction.thatReturnsThis = function () { | ||
return this; | ||
}; | ||
emptyFunction.thatReturnsArgument = function (arg) { | ||
return arg; | ||
}; | ||
module.exports = emptyFunction; | ||
/***/ }, | ||
/* 4 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/** | ||
* Copyright 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
"use strict"; | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
if (false) { | ||
var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && | ||
Symbol.for && | ||
Symbol.for('react.element')) || | ||
0xeac7; | ||
var isValidElement = function(object) { | ||
return typeof object === 'object' && | ||
object !== null && | ||
object.$$typeof === REACT_ELEMENT_TYPE; | ||
}; | ||
// By explicitly using `prop-types` you are opting into new development behavior. | ||
// http://fb.me/prop-types-in-prod | ||
var throwOnDirectAccess = true; | ||
module.exports = require('./factoryWithTypeCheckers')(isValidElement, throwOnDirectAccess); | ||
} else { | ||
// By explicitly using `prop-types` you are opting into new production behavior. | ||
// http://fb.me/prop-types-in-prod | ||
module.exports = __webpack_require__(3)(); | ||
} | ||
/** | ||
* Use invariant() to assert state which your program assumes to be true. | ||
* | ||
* Provide sprintf-style format (only %s is supported) and arguments | ||
* to provide information about what broke and what you were | ||
* expecting. | ||
* | ||
* The invariant message will be stripped in production, but the invariant | ||
* will remain to ensure logic does not differ in production. | ||
*/ | ||
var validateFormat = function validateFormat(format) {}; | ||
/***/ }, | ||
/* 5 */ | ||
/***/ function(module, exports) { | ||
if (false) { | ||
validateFormat = function validateFormat(format) { | ||
if (format === undefined) { | ||
throw new Error('invariant requires an error message argument'); | ||
} | ||
}; | ||
} | ||
/** | ||
* Copyright 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
function invariant(condition, format, a, b, c, d, e, f) { | ||
validateFormat(format); | ||
'use strict'; | ||
if (!condition) { | ||
var error; | ||
if (format === undefined) { | ||
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); | ||
} else { | ||
var args = [a, b, c, d, e, f]; | ||
var argIndex = 0; | ||
error = new Error(format.replace(/%s/g, function () { | ||
return args[argIndex++]; | ||
})); | ||
error.name = 'Invariant Violation'; | ||
} | ||
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; | ||
error.framesToPop = 1; // we don't care about invariant's own frame | ||
throw error; | ||
} | ||
} | ||
module.exports = ReactPropTypesSecret; | ||
module.exports = invariant; | ||
/***/ }, | ||
/***/ }), | ||
/* 6 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var __WEBPACK_AMD_DEFINE_RESULT__;/** | ||
* SVGInjector v1.1.3 - Fast, caching, dynamic inline SVG DOM injection library | ||
* https://github.com/iconic/SVGInjector | ||
* | ||
* Copyright (c) 2014-2015 Waybury <hello@waybury.com> | ||
* @license MIT | ||
*/ | ||
"use strict"; | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
(function (window, document) { | ||
'use strict'; | ||
// Environment | ||
var isLocal = window.location.protocol === 'file:'; | ||
var hasSvgSupport = document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#BasicStructure', '1.1'); | ||
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; | ||
function uniqueClasses(list) { | ||
list = list.split(' '); | ||
module.exports = ReactPropTypesSecret; | ||
var hash = {}; | ||
var i = list.length; | ||
var out = []; | ||
while (i--) { | ||
if (!hash.hasOwnProperty(list[i])) { | ||
hash[list[i]] = 1; | ||
out.unshift(list[i]); | ||
} | ||
} | ||
/***/ }), | ||
/* 7 */ | ||
/***/ (function(module, exports) { | ||
return out.join(' '); | ||
} | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_7__; | ||
/** | ||
* cache (or polyfill for <= IE8) Array.forEach() | ||
* source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach | ||
*/ | ||
var forEach = Array.prototype.forEach || function (fn, scope) { | ||
if (this === void 0 || this === null || typeof fn !== 'function') { | ||
throw new TypeError(); | ||
} | ||
/***/ }), | ||
/* 8 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/* jshint bitwise: false */ | ||
var i, len = this.length >>> 0; | ||
/* jshint bitwise: true */ | ||
var __WEBPACK_AMD_DEFINE_RESULT__;/** | ||
* SVGInjector v1.1.3 - Fast, caching, dynamic inline SVG DOM injection library | ||
* https://github.com/iconic/SVGInjector | ||
* | ||
* Copyright (c) 2014-2015 Waybury <hello@waybury.com> | ||
* @license MIT | ||
*/ | ||
for (i = 0; i < len; ++i) { | ||
if (i in this) { | ||
fn.call(scope, this[i], i, this); | ||
} | ||
} | ||
}; | ||
(function (window, document) { | ||
// SVG Cache | ||
var svgCache = {}; | ||
'use strict'; | ||
var injectCount = 0; | ||
var injectedElements = []; | ||
// Environment | ||
var isLocal = window.location.protocol === 'file:'; | ||
var hasSvgSupport = document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#BasicStructure', '1.1'); | ||
// Request Queue | ||
var requestQueue = []; | ||
function uniqueClasses(list) { | ||
list = list.split(' '); | ||
// Script running status | ||
var ranScripts = {}; | ||
var hash = {}; | ||
var i = list.length; | ||
var out = []; | ||
var cloneSvg = function (sourceSvg) { | ||
return sourceSvg.cloneNode(true); | ||
}; | ||
while (i--) { | ||
if (!hash.hasOwnProperty(list[i])) { | ||
hash[list[i]] = 1; | ||
out.unshift(list[i]); | ||
} | ||
} | ||
var queueRequest = function (url, callback) { | ||
requestQueue[url] = requestQueue[url] || []; | ||
requestQueue[url].push(callback); | ||
}; | ||
return out.join(' '); | ||
} | ||
var processRequestQueue = function (url) { | ||
for (var i = 0, len = requestQueue[url].length; i < len; i++) { | ||
// Make these calls async so we avoid blocking the page/renderer | ||
/* jshint loopfunc: true */ | ||
(function (index) { | ||
setTimeout(function () { | ||
requestQueue[url][index](cloneSvg(svgCache[url])); | ||
}, 0); | ||
})(i); | ||
/* jshint loopfunc: false */ | ||
} | ||
}; | ||
/** | ||
* cache (or polyfill for <= IE8) Array.forEach() | ||
* source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach | ||
*/ | ||
var forEach = Array.prototype.forEach || function (fn, scope) { | ||
if (this === void 0 || this === null || typeof fn !== 'function') { | ||
throw new TypeError(); | ||
} | ||
var loadSvg = function (url, callback) { | ||
if (svgCache[url] !== undefined) { | ||
if (svgCache[url] instanceof SVGSVGElement) { | ||
// We already have it in cache, so use it | ||
callback(cloneSvg(svgCache[url])); | ||
} | ||
else { | ||
// We don't have it in cache yet, but we are loading it, so queue this request | ||
queueRequest(url, callback); | ||
} | ||
} | ||
else { | ||
/* jshint bitwise: false */ | ||
var i, len = this.length >>> 0; | ||
/* jshint bitwise: true */ | ||
if (!window.XMLHttpRequest) { | ||
callback('Browser does not support XMLHttpRequest'); | ||
return false; | ||
} | ||
for (i = 0; i < len; ++i) { | ||
if (i in this) { | ||
fn.call(scope, this[i], i, this); | ||
} | ||
} | ||
}; | ||
// Seed the cache to indicate we are loading this URL already | ||
svgCache[url] = {}; | ||
queueRequest(url, callback); | ||
// SVG Cache | ||
var svgCache = {}; | ||
var httpRequest = new XMLHttpRequest(); | ||
var injectCount = 0; | ||
var injectedElements = []; | ||
httpRequest.onreadystatechange = function () { | ||
// readyState 4 = complete | ||
if (httpRequest.readyState === 4) { | ||
// Request Queue | ||
var requestQueue = []; | ||
// Handle status | ||
if (httpRequest.status === 404 || httpRequest.responseXML === null) { | ||
callback('Unable to load SVG file: ' + url); | ||
// Script running status | ||
var ranScripts = {}; | ||
if (isLocal) callback('Note: SVG injection ajax calls do not work locally without adjusting security setting in your browser. Or consider using a local webserver.'); | ||
var cloneSvg = function (sourceSvg) { | ||
return sourceSvg.cloneNode(true); | ||
}; | ||
callback(); | ||
return false; | ||
} | ||
var queueRequest = function (url, callback) { | ||
requestQueue[url] = requestQueue[url] || []; | ||
requestQueue[url].push(callback); | ||
}; | ||
// 200 success from server, or 0 when using file:// protocol locally | ||
if (httpRequest.status === 200 || (isLocal && httpRequest.status === 0)) { | ||
var processRequestQueue = function (url) { | ||
for (var i = 0, len = requestQueue[url].length; i < len; i++) { | ||
// Make these calls async so we avoid blocking the page/renderer | ||
/* jshint loopfunc: true */ | ||
(function (index) { | ||
setTimeout(function () { | ||
requestQueue[url][index](cloneSvg(svgCache[url])); | ||
}, 0); | ||
})(i); | ||
/* jshint loopfunc: false */ | ||
} | ||
}; | ||
/* globals Document */ | ||
if (httpRequest.responseXML instanceof Document) { | ||
// Cache it | ||
svgCache[url] = httpRequest.responseXML.documentElement; | ||
} | ||
/* globals -Document */ | ||
var loadSvg = function (url, callback) { | ||
if (svgCache[url] !== undefined) { | ||
if (svgCache[url] instanceof SVGSVGElement) { | ||
// We already have it in cache, so use it | ||
callback(cloneSvg(svgCache[url])); | ||
} | ||
else { | ||
// We don't have it in cache yet, but we are loading it, so queue this request | ||
queueRequest(url, callback); | ||
} | ||
} | ||
else { | ||
// IE9 doesn't create a responseXML Document object from loaded SVG, | ||
// and throws a "DOM Exception: HIERARCHY_REQUEST_ERR (3)" error when injected. | ||
// | ||
// So, we'll just create our own manually via the DOMParser using | ||
// the the raw XML responseText. | ||
// | ||
// :NOTE: IE8 and older doesn't have DOMParser, but they can't do SVG either, so... | ||
else if (DOMParser && (DOMParser instanceof Function)) { | ||
var xmlDoc; | ||
try { | ||
var parser = new DOMParser(); | ||
xmlDoc = parser.parseFromString(httpRequest.responseText, 'text/xml'); | ||
} | ||
catch (e) { | ||
xmlDoc = undefined; | ||
} | ||
if (!window.XMLHttpRequest) { | ||
callback('Browser does not support XMLHttpRequest'); | ||
return false; | ||
} | ||
if (!xmlDoc || xmlDoc.getElementsByTagName('parsererror').length) { | ||
callback('Unable to parse SVG file: ' + url); | ||
return false; | ||
} | ||
else { | ||
// Cache it | ||
svgCache[url] = xmlDoc.documentElement; | ||
} | ||
} | ||
// Seed the cache to indicate we are loading this URL already | ||
svgCache[url] = {}; | ||
queueRequest(url, callback); | ||
// We've loaded a new asset, so process any requests waiting for it | ||
processRequestQueue(url); | ||
} | ||
else { | ||
callback('There was a problem injecting the SVG: ' + httpRequest.status + ' ' + httpRequest.statusText); | ||
return false; | ||
} | ||
} | ||
}; | ||
var httpRequest = new XMLHttpRequest(); | ||
httpRequest.open('GET', url); | ||
httpRequest.onreadystatechange = function () { | ||
// readyState 4 = complete | ||
if (httpRequest.readyState === 4) { | ||
// Treat and parse the response as XML, even if the | ||
// server sends us a different mimetype | ||
if (httpRequest.overrideMimeType) httpRequest.overrideMimeType('text/xml'); | ||
// Handle status | ||
if (httpRequest.status === 404 || httpRequest.responseXML === null) { | ||
callback('Unable to load SVG file: ' + url); | ||
httpRequest.send(); | ||
} | ||
}; | ||
if (isLocal) callback('Note: SVG injection ajax calls do not work locally without adjusting security setting in your browser. Or consider using a local webserver.'); | ||
// Inject a single element | ||
var injectElement = function (el, evalScripts, pngFallback, callback) { | ||
callback(); | ||
return false; | ||
} | ||
// Grab the src or data-src attribute | ||
var imgUrl = el.getAttribute('data-src') || el.getAttribute('src'); | ||
// 200 success from server, or 0 when using file:// protocol locally | ||
if (httpRequest.status === 200 || (isLocal && httpRequest.status === 0)) { | ||
// We can only inject SVG | ||
if (!(/\.svg/i).test(imgUrl)) { | ||
callback('Attempted to inject a file with a non-svg extension: ' + imgUrl); | ||
return; | ||
} | ||
/* globals Document */ | ||
if (httpRequest.responseXML instanceof Document) { | ||
// Cache it | ||
svgCache[url] = httpRequest.responseXML.documentElement; | ||
} | ||
/* globals -Document */ | ||
// If we don't have SVG support try to fall back to a png, | ||
// either defined per-element via data-fallback or data-png, | ||
// or globally via the pngFallback directory setting | ||
if (!hasSvgSupport) { | ||
var perElementFallback = el.getAttribute('data-fallback') || el.getAttribute('data-png'); | ||
// IE9 doesn't create a responseXML Document object from loaded SVG, | ||
// and throws a "DOM Exception: HIERARCHY_REQUEST_ERR (3)" error when injected. | ||
// | ||
// So, we'll just create our own manually via the DOMParser using | ||
// the the raw XML responseText. | ||
// | ||
// :NOTE: IE8 and older doesn't have DOMParser, but they can't do SVG either, so... | ||
else if (DOMParser && (DOMParser instanceof Function)) { | ||
var xmlDoc; | ||
try { | ||
var parser = new DOMParser(); | ||
xmlDoc = parser.parseFromString(httpRequest.responseText, 'text/xml'); | ||
} | ||
catch (e) { | ||
xmlDoc = undefined; | ||
} | ||
// Per-element specific PNG fallback defined, so use that | ||
if (perElementFallback) { | ||
el.setAttribute('src', perElementFallback); | ||
callback(null); | ||
} | ||
// Global PNG fallback directoriy defined, use the same-named PNG | ||
else if (pngFallback) { | ||
el.setAttribute('src', pngFallback + '/' + imgUrl.split('/').pop().replace('.svg', '.png')); | ||
callback(null); | ||
} | ||
// um... | ||
else { | ||
callback('This browser does not support SVG and no PNG fallback was defined.'); | ||
} | ||
if (!xmlDoc || xmlDoc.getElementsByTagName('parsererror').length) { | ||
callback('Unable to parse SVG file: ' + url); | ||
return false; | ||
} | ||
else { | ||
// Cache it | ||
svgCache[url] = xmlDoc.documentElement; | ||
} | ||
} | ||
return; | ||
} | ||
// We've loaded a new asset, so process any requests waiting for it | ||
processRequestQueue(url); | ||
} | ||
else { | ||
callback('There was a problem injecting the SVG: ' + httpRequest.status + ' ' + httpRequest.statusText); | ||
return false; | ||
} | ||
} | ||
}; | ||
// Make sure we aren't already in the process of injecting this element to | ||
// avoid a race condition if multiple injections for the same element are run. | ||
// :NOTE: Using indexOf() only _after_ we check for SVG support and bail, | ||
// so no need for IE8 indexOf() polyfill | ||
if (injectedElements.indexOf(el) !== -1) { | ||
return; | ||
} | ||
httpRequest.open('GET', url); | ||
// Remember the request to inject this element, in case other injection | ||
// calls are also trying to replace this element before we finish | ||
injectedElements.push(el); | ||
// Treat and parse the response as XML, even if the | ||
// server sends us a different mimetype | ||
if (httpRequest.overrideMimeType) httpRequest.overrideMimeType('text/xml'); | ||
// Try to avoid loading the orginal image src if possible. | ||
el.setAttribute('src', ''); | ||
httpRequest.send(); | ||
} | ||
}; | ||
// Load it up | ||
loadSvg(imgUrl, function (svg) { | ||
// Inject a single element | ||
var injectElement = function (el, evalScripts, pngFallback, callback) { | ||
if (typeof svg === 'undefined' || typeof svg === 'string') { | ||
callback(svg); | ||
return false; | ||
} | ||
// Grab the src or data-src attribute | ||
var imgUrl = el.getAttribute('data-src') || el.getAttribute('src'); | ||
var imgId = el.getAttribute('id'); | ||
if (imgId) { | ||
svg.setAttribute('id', imgId); | ||
} | ||
// We can only inject SVG | ||
if (!(/\.svg/i).test(imgUrl)) { | ||
callback('Attempted to inject a file with a non-svg extension: ' + imgUrl); | ||
return; | ||
} | ||
var imgTitle = el.getAttribute('title'); | ||
if (imgTitle) { | ||
svg.setAttribute('title', imgTitle); | ||
} | ||
// If we don't have SVG support try to fall back to a png, | ||
// either defined per-element via data-fallback or data-png, | ||
// or globally via the pngFallback directory setting | ||
if (!hasSvgSupport) { | ||
var perElementFallback = el.getAttribute('data-fallback') || el.getAttribute('data-png'); | ||
// Concat the SVG classes + 'injected-svg' + the img classes | ||
var classMerge = [].concat(svg.getAttribute('class') || [], 'injected-svg', el.getAttribute('class') || []).join(' '); | ||
svg.setAttribute('class', uniqueClasses(classMerge)); | ||
// Per-element specific PNG fallback defined, so use that | ||
if (perElementFallback) { | ||
el.setAttribute('src', perElementFallback); | ||
callback(null); | ||
} | ||
// Global PNG fallback directoriy defined, use the same-named PNG | ||
else if (pngFallback) { | ||
el.setAttribute('src', pngFallback + '/' + imgUrl.split('/').pop().replace('.svg', '.png')); | ||
callback(null); | ||
} | ||
// um... | ||
else { | ||
callback('This browser does not support SVG and no PNG fallback was defined.'); | ||
} | ||
var imgStyle = el.getAttribute('style'); | ||
if (imgStyle) { | ||
svg.setAttribute('style', imgStyle); | ||
} | ||
return; | ||
} | ||
// Copy all the data elements to the svg | ||
var imgData = [].filter.call(el.attributes, function (at) { | ||
return (/^data-\w[\w\-]*$/).test(at.name); | ||
}); | ||
forEach.call(imgData, function (dataAttr) { | ||
if (dataAttr.name && dataAttr.value) { | ||
svg.setAttribute(dataAttr.name, dataAttr.value); | ||
} | ||
}); | ||
// Make sure we aren't already in the process of injecting this element to | ||
// avoid a race condition if multiple injections for the same element are run. | ||
// :NOTE: Using indexOf() only _after_ we check for SVG support and bail, | ||
// so no need for IE8 indexOf() polyfill | ||
if (injectedElements.indexOf(el) !== -1) { | ||
return; | ||
} | ||
// Make sure any internally referenced clipPath ids and their | ||
// clip-path references are unique. | ||
// | ||
// This addresses the issue of having multiple instances of the | ||
// same SVG on a page and only the first clipPath id is referenced. | ||
// | ||
// Browsers often shortcut the SVG Spec and don't use clipPaths | ||
// contained in parent elements that are hidden, so if you hide the first | ||
// SVG instance on the page, then all other instances lose their clipping. | ||
// Reference: https://bugzilla.mozilla.org/show_bug.cgi?id=376027 | ||
// Remember the request to inject this element, in case other injection | ||
// calls are also trying to replace this element before we finish | ||
injectedElements.push(el); | ||
// Handle all defs elements that have iri capable attributes as defined by w3c: http://www.w3.org/TR/SVG/linking.html#processingIRI | ||
// Mapping IRI addressable elements to the properties that can reference them: | ||
var iriElementsAndProperties = { | ||
'clipPath': ['clip-path'], | ||
'color-profile': ['color-profile'], | ||
'cursor': ['cursor'], | ||
'filter': ['filter'], | ||
'linearGradient': ['fill', 'stroke'], | ||
'marker': ['marker', 'marker-start', 'marker-mid', 'marker-end'], | ||
'mask': ['mask'], | ||
'pattern': ['fill', 'stroke'], | ||
'radialGradient': ['fill', 'stroke'] | ||
}; | ||
// Try to avoid loading the orginal image src if possible. | ||
el.setAttribute('src', ''); | ||
var element, elementDefs, properties, currentId, newId; | ||
Object.keys(iriElementsAndProperties).forEach(function (key) { | ||
element = key; | ||
properties = iriElementsAndProperties[key]; | ||
// Load it up | ||
loadSvg(imgUrl, function (svg) { | ||
elementDefs = svg.querySelectorAll('defs ' + element + '[id]'); | ||
for (var i = 0, elementsLen = elementDefs.length; i < elementsLen; i++) { | ||
currentId = elementDefs[i].id; | ||
newId = currentId + '-' + injectCount; | ||
if (typeof svg === 'undefined' || typeof svg === 'string') { | ||
callback(svg); | ||
return false; | ||
} | ||
// All of the properties that can reference this element type | ||
var referencingElements; | ||
forEach.call(properties, function (property) { | ||
// :NOTE: using a substring match attr selector here to deal with IE "adding extra quotes in url() attrs" | ||
referencingElements = svg.querySelectorAll('[' + property + '*="' + currentId + '"]'); | ||
for (var j = 0, referencingElementLen = referencingElements.length; j < referencingElementLen; j++) { | ||
referencingElements[j].setAttribute(property, 'url(#' + newId + ')'); | ||
} | ||
}); | ||
var imgId = el.getAttribute('id'); | ||
if (imgId) { | ||
svg.setAttribute('id', imgId); | ||
} | ||
elementDefs[i].id = newId; | ||
} | ||
}); | ||
var imgTitle = el.getAttribute('title'); | ||
if (imgTitle) { | ||
svg.setAttribute('title', imgTitle); | ||
} | ||
// Remove any unwanted/invalid namespaces that might have been added by SVG editing tools | ||
svg.removeAttribute('xmlns:a'); | ||
// Concat the SVG classes + 'injected-svg' + the img classes | ||
var classMerge = [].concat(svg.getAttribute('class') || [], 'injected-svg', el.getAttribute('class') || []).join(' '); | ||
svg.setAttribute('class', uniqueClasses(classMerge)); | ||
// Post page load injected SVGs don't automatically have their script | ||
// elements run, so we'll need to make that happen, if requested | ||
var imgStyle = el.getAttribute('style'); | ||
if (imgStyle) { | ||
svg.setAttribute('style', imgStyle); | ||
} | ||
// Find then prune the scripts | ||
var scripts = svg.querySelectorAll('script'); | ||
var scriptsToEval = []; | ||
var script, scriptType; | ||
// Copy all the data elements to the svg | ||
var imgData = [].filter.call(el.attributes, function (at) { | ||
return (/^data-\w[\w\-]*$/).test(at.name); | ||
}); | ||
forEach.call(imgData, function (dataAttr) { | ||
if (dataAttr.name && dataAttr.value) { | ||
svg.setAttribute(dataAttr.name, dataAttr.value); | ||
} | ||
}); | ||
for (var k = 0, scriptsLen = scripts.length; k < scriptsLen; k++) { | ||
scriptType = scripts[k].getAttribute('type'); | ||
// Make sure any internally referenced clipPath ids and their | ||
// clip-path references are unique. | ||
// | ||
// This addresses the issue of having multiple instances of the | ||
// same SVG on a page and only the first clipPath id is referenced. | ||
// | ||
// Browsers often shortcut the SVG Spec and don't use clipPaths | ||
// contained in parent elements that are hidden, so if you hide the first | ||
// SVG instance on the page, then all other instances lose their clipping. | ||
// Reference: https://bugzilla.mozilla.org/show_bug.cgi?id=376027 | ||
// Only process javascript types. | ||
// SVG defaults to 'application/ecmascript' for unset types | ||
if (!scriptType || scriptType === 'application/ecmascript' || scriptType === 'application/javascript') { | ||
// Handle all defs elements that have iri capable attributes as defined by w3c: http://www.w3.org/TR/SVG/linking.html#processingIRI | ||
// Mapping IRI addressable elements to the properties that can reference them: | ||
var iriElementsAndProperties = { | ||
'clipPath': ['clip-path'], | ||
'color-profile': ['color-profile'], | ||
'cursor': ['cursor'], | ||
'filter': ['filter'], | ||
'linearGradient': ['fill', 'stroke'], | ||
'marker': ['marker', 'marker-start', 'marker-mid', 'marker-end'], | ||
'mask': ['mask'], | ||
'pattern': ['fill', 'stroke'], | ||
'radialGradient': ['fill', 'stroke'] | ||
}; | ||
// innerText for IE, textContent for other browsers | ||
script = scripts[k].innerText || scripts[k].textContent; | ||
var element, elementDefs, properties, currentId, newId; | ||
Object.keys(iriElementsAndProperties).forEach(function (key) { | ||
element = key; | ||
properties = iriElementsAndProperties[key]; | ||
// Stash | ||
scriptsToEval.push(script); | ||
elementDefs = svg.querySelectorAll('defs ' + element + '[id]'); | ||
for (var i = 0, elementsLen = elementDefs.length; i < elementsLen; i++) { | ||
currentId = elementDefs[i].id; | ||
newId = currentId + '-' + injectCount; | ||
// Tidy up and remove the script element since we don't need it anymore | ||
svg.removeChild(scripts[k]); | ||
} | ||
} | ||
// All of the properties that can reference this element type | ||
var referencingElements; | ||
forEach.call(properties, function (property) { | ||
// :NOTE: using a substring match attr selector here to deal with IE "adding extra quotes in url() attrs" | ||
referencingElements = svg.querySelectorAll('[' + property + '*="' + currentId + '"]'); | ||
for (var j = 0, referencingElementLen = referencingElements.length; j < referencingElementLen; j++) { | ||
referencingElements[j].setAttribute(property, 'url(#' + newId + ')'); | ||
} | ||
}); | ||
// Run/Eval the scripts if needed | ||
if (scriptsToEval.length > 0 && (evalScripts === 'always' || (evalScripts === 'once' && !ranScripts[imgUrl]))) { | ||
for (var l = 0, scriptsToEvalLen = scriptsToEval.length; l < scriptsToEvalLen; l++) { | ||
elementDefs[i].id = newId; | ||
} | ||
}); | ||
// :NOTE: Yup, this is a form of eval, but it is being used to eval code | ||
// the caller has explictely asked to be loaded, and the code is in a caller | ||
// defined SVG file... not raw user input. | ||
// | ||
// Also, the code is evaluated in a closure and not in the global scope. | ||
// If you need to put something in global scope, use 'window' | ||
new Function(scriptsToEval[l])(window); // jshint ignore:line | ||
} | ||
// Remove any unwanted/invalid namespaces that might have been added by SVG editing tools | ||
svg.removeAttribute('xmlns:a'); | ||
// Remember we already ran scripts for this svg | ||
ranScripts[imgUrl] = true; | ||
} | ||
// Post page load injected SVGs don't automatically have their script | ||
// elements run, so we'll need to make that happen, if requested | ||
// :WORKAROUND: | ||
// IE doesn't evaluate <style> tags in SVGs that are dynamically added to the page. | ||
// This trick will trigger IE to read and use any existing SVG <style> tags. | ||
// | ||
// Reference: https://github.com/iconic/SVGInjector/issues/23 | ||
var styleTags = svg.querySelectorAll('style'); | ||
forEach.call(styleTags, function (styleTag) { | ||
styleTag.textContent += ''; | ||
}); | ||
// Find then prune the scripts | ||
var scripts = svg.querySelectorAll('script'); | ||
var scriptsToEval = []; | ||
var script, scriptType; | ||
// Replace the image with the svg | ||
el.parentNode.replaceChild(svg, el); | ||
for (var k = 0, scriptsLen = scripts.length; k < scriptsLen; k++) { | ||
scriptType = scripts[k].getAttribute('type'); | ||
// Now that we no longer need it, drop references | ||
// to the original element so it can be GC'd | ||
delete injectedElements[injectedElements.indexOf(el)]; | ||
el = null; | ||
// Only process javascript types. | ||
// SVG defaults to 'application/ecmascript' for unset types | ||
if (!scriptType || scriptType === 'application/ecmascript' || scriptType === 'application/javascript') { | ||
// Increment the injected count | ||
injectCount++; | ||
// innerText for IE, textContent for other browsers | ||
script = scripts[k].innerText || scripts[k].textContent; | ||
callback(svg); | ||
}); | ||
}; | ||
// Stash | ||
scriptsToEval.push(script); | ||
/** | ||
* SVGInjector | ||
* | ||
* Replace the given elements with their full inline SVG DOM elements. | ||
* | ||
* :NOTE: We are using get/setAttribute with SVG because the SVG DOM spec differs from HTML DOM and | ||
* can return other unexpected object types when trying to directly access svg properties. | ||
* ex: "className" returns a SVGAnimatedString with the class value found in the "baseVal" property, | ||
* instead of simple string like with HTML Elements. | ||
* | ||
* @param {mixes} Array of or single DOM element | ||
* @param {object} options | ||
* @param {function} callback | ||
* @return {object} Instance of SVGInjector | ||
*/ | ||
var SVGInjector = function (elements, options, done) { | ||
// Tidy up and remove the script element since we don't need it anymore | ||
svg.removeChild(scripts[k]); | ||
} | ||
} | ||
// Options & defaults | ||
options = options || {}; | ||
// Run/Eval the scripts if needed | ||
if (scriptsToEval.length > 0 && (evalScripts === 'always' || (evalScripts === 'once' && !ranScripts[imgUrl]))) { | ||
for (var l = 0, scriptsToEvalLen = scriptsToEval.length; l < scriptsToEvalLen; l++) { | ||
// Should we run the scripts blocks found in the SVG | ||
// 'always' - Run them every time | ||
// 'once' - Only run scripts once for each SVG | ||
// [false|'never'] - Ignore scripts | ||
var evalScripts = options.evalScripts || 'always'; | ||
// :NOTE: Yup, this is a form of eval, but it is being used to eval code | ||
// the caller has explictely asked to be loaded, and the code is in a caller | ||
// defined SVG file... not raw user input. | ||
// | ||
// Also, the code is evaluated in a closure and not in the global scope. | ||
// If you need to put something in global scope, use 'window' | ||
new Function(scriptsToEval[l])(window); // jshint ignore:line | ||
} | ||
// Location of fallback pngs, if desired | ||
var pngFallback = options.pngFallback || false; | ||
// Remember we already ran scripts for this svg | ||
ranScripts[imgUrl] = true; | ||
} | ||
// Callback to run during each SVG injection, returning the SVG injected | ||
var eachCallback = options.each; | ||
// :WORKAROUND: | ||
// IE doesn't evaluate <style> tags in SVGs that are dynamically added to the page. | ||
// This trick will trigger IE to read and use any existing SVG <style> tags. | ||
// | ||
// Reference: https://github.com/iconic/SVGInjector/issues/23 | ||
var styleTags = svg.querySelectorAll('style'); | ||
forEach.call(styleTags, function (styleTag) { | ||
styleTag.textContent += ''; | ||
}); | ||
// Do the injection... | ||
if (elements.length !== undefined) { | ||
var elementsLoaded = 0; | ||
forEach.call(elements, function (element) { | ||
injectElement(element, evalScripts, pngFallback, function (svg) { | ||
if (eachCallback && typeof eachCallback === 'function') eachCallback(svg); | ||
if (done && elements.length === ++elementsLoaded) done(elementsLoaded); | ||
}); | ||
}); | ||
} | ||
else { | ||
if (elements) { | ||
injectElement(elements, evalScripts, pngFallback, function (svg) { | ||
if (eachCallback && typeof eachCallback === 'function') eachCallback(svg); | ||
if (done) done(1); | ||
elements = null; | ||
}); | ||
} | ||
else { | ||
if (done) done(0); | ||
} | ||
} | ||
}; | ||
// Replace the image with the svg | ||
el.parentNode.replaceChild(svg, el); | ||
/* global module, exports: true, define */ | ||
// Node.js or CommonJS | ||
if (typeof module === 'object' && typeof module.exports === 'object') { | ||
module.exports = exports = SVGInjector; | ||
} | ||
// AMD support | ||
else if (true) { | ||
!(__WEBPACK_AMD_DEFINE_RESULT__ = function () { | ||
return SVGInjector; | ||
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
} | ||
// Otherwise, attach to window as global | ||
else if (typeof window === 'object') { | ||
window.SVGInjector = SVGInjector; | ||
} | ||
/* global -module, -exports, -define */ | ||
// Now that we no longer need it, drop references | ||
// to the original element so it can be GC'd | ||
delete injectedElements[injectedElements.indexOf(el)]; | ||
el = null; | ||
}(window, document)); | ||
// Increment the injected count | ||
injectCount++; | ||
callback(svg); | ||
}); | ||
}; | ||
/***/ }, | ||
/* 7 */ | ||
/***/ function(module, exports) { | ||
/** | ||
* SVGInjector | ||
* | ||
* Replace the given elements with their full inline SVG DOM elements. | ||
* | ||
* :NOTE: We are using get/setAttribute with SVG because the SVG DOM spec differs from HTML DOM and | ||
* can return other unexpected object types when trying to directly access svg properties. | ||
* ex: "className" returns a SVGAnimatedString with the class value found in the "baseVal" property, | ||
* instead of simple string like with HTML Elements. | ||
* | ||
* @param {mixes} Array of or single DOM element | ||
* @param {object} options | ||
* @param {function} callback | ||
* @return {object} Instance of SVGInjector | ||
*/ | ||
var SVGInjector = function (elements, options, done) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_7__; | ||
// Options & defaults | ||
options = options || {}; | ||
/***/ }, | ||
/* 8 */ | ||
/***/ function(module, exports) { | ||
// Should we run the scripts blocks found in the SVG | ||
// 'always' - Run them every time | ||
// 'once' - Only run scripts once for each SVG | ||
// [false|'never'] - Ignore scripts | ||
var evalScripts = options.evalScripts || 'always'; | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_8__; | ||
// Location of fallback pngs, if desired | ||
var pngFallback = options.pngFallback || false; | ||
/***/ } | ||
/******/ ]) | ||
}); | ||
; | ||
// Callback to run during each SVG injection, returning the SVG injected | ||
var eachCallback = options.each; | ||
// Do the injection... | ||
if (elements.length !== undefined) { | ||
var elementsLoaded = 0; | ||
forEach.call(elements, function (element) { | ||
injectElement(element, evalScripts, pngFallback, function (svg) { | ||
if (eachCallback && typeof eachCallback === 'function') eachCallback(svg); | ||
if (done && elements.length === ++elementsLoaded) done(elementsLoaded); | ||
}); | ||
}); | ||
} | ||
else { | ||
if (elements) { | ||
injectElement(elements, evalScripts, pngFallback, function (svg) { | ||
if (eachCallback && typeof eachCallback === 'function') eachCallback(svg); | ||
if (done) done(1); | ||
elements = null; | ||
}); | ||
} | ||
else { | ||
if (done) done(0); | ||
} | ||
} | ||
}; | ||
/* global module, exports: true, define */ | ||
// Node.js or CommonJS | ||
if (typeof module === 'object' && typeof module.exports === 'object') { | ||
module.exports = exports = SVGInjector; | ||
} | ||
// AMD support | ||
else if (true) { | ||
!(__WEBPACK_AMD_DEFINE_RESULT__ = function () { | ||
return SVGInjector; | ||
}.call(exports, __webpack_require__, exports, module), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
} | ||
// Otherwise, attach to window as global | ||
else if (typeof window === 'object') { | ||
window.SVGInjector = SVGInjector; | ||
} | ||
/* global -module, -exports, -define */ | ||
}(window, document)); | ||
/***/ }) | ||
/******/ ]); | ||
}); |
@@ -1,8 +0,8 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom/server")):"function"==typeof define&&define.amd?define(["react","react-dom/server"],t):"object"==typeof exports?exports.ReactSVG=t(require("react"),require("react-dom/server")):e.ReactSVG=t(e.React,e.ReactDOMServer)}(this,function(e,t){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),u=r(7),l=n(u),c=r(4),f=n(c),p=r(8),d=n(p),v="undefined"!=typeof window,h=v?r(6):void 0,y=function(e){function t(){var e,r,n,a;o(this,t);for(var s=arguments.length,u=Array(s),l=0;l<s;l++)u[l]=arguments[l];return r=n=i(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(u))),n.refCallback=function(e){return e?(n.container=e,void n.renderSVG()):void n.removeSVG()},a=r,i(n,a)}return a(t,e),s(t,[{key:"renderSVG",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props,t=e.callback,r=e.className,n=e.evalScripts,o=e.path,i=e.style,a=document.createElement("div");a.innerHTML=d.default.renderToStaticMarkup(l.default.createElement("div",null,l.default.createElement("div",{className:r,"data-src":o,style:i})));var s=this.container.appendChild(a.firstChild);h(s.firstChild,{evalScripts:n,each:t})}},{key:"removeSVG",value:function(){this.container.removeChild(this.container.firstChild)}},{key:"componentWillReceiveProps",value:function(e){this.removeSVG(),this.renderSVG(e)}},{key:"shouldComponentUpdate",value:function(){return!1}},{key:"render",value:function(){return l.default.createElement("div",{ref:this.refCallback})}}]),t}(u.Component);y.defaultProps={callback:function(){},className:"",evalScripts:"once",style:{}},y.propTypes={callback:f.default.func,className:f.default.string,evalScripts:f.default.oneOf(["always","once","never"]),path:f.default.string.isRequired,style:f.default.object},t.default=y,e.exports=t.default},function(e,t){"use strict";function r(e){return function(){return e}}var n=function(){};n.thatReturns=r,n.thatReturnsFalse=r(!1),n.thatReturnsTrue=r(!0),n.thatReturnsNull=r(null),n.thatReturnsThis=function(){return this},n.thatReturnsArgument=function(e){return e},e.exports=n},function(e,t,r){"use strict";function n(e,t,r,n,i,a,s,u){if(o(t),!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[r,n,i,a,s,u],f=0;l=new Error(t.replace(/%s/g,function(){return c[f++]})),l.name="Invariant Violation"}throw l.framesToPop=1,l}}var o=function(e){};e.exports=n},function(e,t,r){"use strict";var n=r(1),o=r(2),i=r(5);e.exports=function(){function e(e,t,r,n,a,s){s!==i&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t};return r.checkPropTypes=n,r.PropTypes=r,r}},function(e,t,r){e.exports=r(3)()},function(e,t){"use strict";var r="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=r},function(e,t,r){var n;/** | ||
* SVGInjector v1.1.3 - Fast, caching, dynamic inline SVG DOM injection library | ||
* https://github.com/iconic/SVGInjector | ||
* | ||
* Copyright (c) 2014-2015 Waybury <hello@waybury.com> | ||
* @license MIT | ||
*/ | ||
!function(o,i){"use strict";function a(e){e=e.split(" ");for(var t={},r=e.length,n=[];r--;)t.hasOwnProperty(e[r])||(t[e[r]]=1,n.unshift(e[r]));return n.join(" ")}var s="file:"===o.location.protocol,u=i.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1"),l=Array.prototype.forEach||function(e,t){if(void 0===this||null===this||"function"!=typeof e)throw new TypeError;var r,n=this.length>>>0;for(r=0;r<n;++r)r in this&&e.call(t,this[r],r,this)},c={},f=0,p=[],d=[],v={},h=function(e){return e.cloneNode(!0)},y=function(e,t){d[e]=d[e]||[],d[e].push(t)},m=function(e){for(var t=0,r=d[e].length;t<r;t++)!function(t){setTimeout(function(){d[e][t](h(c[e]))},0)}(t)},b=function(e,t){if(void 0!==c[e])c[e]instanceof SVGSVGElement?t(h(c[e])):y(e,t);else{if(!o.XMLHttpRequest)return t("Browser does not support XMLHttpRequest"),!1;c[e]={},y(e,t);var r=new XMLHttpRequest;r.onreadystatechange=function(){if(4===r.readyState){if(404===r.status||null===r.responseXML)return t("Unable to load SVG file: "+e),s&&t("Note: SVG injection ajax calls do not work locally without adjusting security setting in your browser. Or consider using a local webserver."),t(),!1;if(!(200===r.status||s&&0===r.status))return t("There was a problem injecting the SVG: "+r.status+" "+r.statusText),!1;if(r.responseXML instanceof Document)c[e]=r.responseXML.documentElement;else if(DOMParser&&DOMParser instanceof Function){var n;try{var o=new DOMParser;n=o.parseFromString(r.responseText,"text/xml")}catch(e){n=void 0}if(!n||n.getElementsByTagName("parsererror").length)return t("Unable to parse SVG file: "+e),!1;c[e]=n.documentElement}m(e)}},r.open("GET",e),r.overrideMimeType&&r.overrideMimeType("text/xml"),r.send()}},g=function(e,t,r,n){var i=e.getAttribute("data-src")||e.getAttribute("src");if(!/\.svg/i.test(i))return void n("Attempted to inject a file with a non-svg extension: "+i);if(!u){var s=e.getAttribute("data-fallback")||e.getAttribute("data-png");return void(s?(e.setAttribute("src",s),n(null)):r?(e.setAttribute("src",r+"/"+i.split("/").pop().replace(".svg",".png")),n(null)):n("This browser does not support SVG and no PNG fallback was defined."))}p.indexOf(e)===-1&&(p.push(e),e.setAttribute("src",""),b(i,function(r){if("undefined"==typeof r||"string"==typeof r)return n(r),!1;var s=e.getAttribute("id");s&&r.setAttribute("id",s);var u=e.getAttribute("title");u&&r.setAttribute("title",u);var c=[].concat(r.getAttribute("class")||[],"injected-svg",e.getAttribute("class")||[]).join(" ");r.setAttribute("class",a(c));var d=e.getAttribute("style");d&&r.setAttribute("style",d);var h=[].filter.call(e.attributes,function(e){return/^data-\w[\w\-]*$/.test(e.name)});l.call(h,function(e){e.name&&e.value&&r.setAttribute(e.name,e.value)});var y,m,b,g,w,x={clipPath:["clip-path"],"color-profile":["color-profile"],cursor:["cursor"],filter:["filter"],linearGradient:["fill","stroke"],marker:["marker","marker-start","marker-mid","marker-end"],mask:["mask"],pattern:["fill","stroke"],radialGradient:["fill","stroke"]};Object.keys(x).forEach(function(e){y=e,b=x[e],m=r.querySelectorAll("defs "+y+"[id]");for(var t=0,n=m.length;t<n;t++){g=m[t].id,w=g+"-"+f;var o;l.call(b,function(e){o=r.querySelectorAll("["+e+'*="'+g+'"]');for(var t=0,n=o.length;t<n;t++)o[t].setAttribute(e,"url(#"+w+")")}),m[t].id=w}}),r.removeAttribute("xmlns:a");for(var S,k,A=r.querySelectorAll("script"),T=[],O=0,j=A.length;O<j;O++)k=A[O].getAttribute("type"),k&&"application/ecmascript"!==k&&"application/javascript"!==k||(S=A[O].innerText||A[O].textContent,T.push(S),r.removeChild(A[O]));if(T.length>0&&("always"===t||"once"===t&&!v[i])){for(var R=0,E=T.length;R<E;R++)new Function(T[R])(o);v[i]=!0}var _=r.querySelectorAll("style");l.call(_,function(e){e.textContent+=""}),e.parentNode.replaceChild(r,e),delete p[p.indexOf(e)],e=null,f++,n(r)}))},w=function(e,t,r){t=t||{};var n=t.evalScripts||"always",o=t.pngFallback||!1,i=t.each;if(void 0!==e.length){var a=0;l.call(e,function(t){g(t,n,o,function(t){i&&"function"==typeof i&&i(t),r&&e.length===++a&&r(a)})})}else e?g(e,n,o,function(t){i&&"function"==typeof i&&i(t),r&&r(1),e=null}):r&&r(0)};"object"==typeof e&&"object"==typeof e.exports?e.exports=t=w:(n=function(){return w}.call(t,r,t,e),!(void 0!==n&&(e.exports=n)))}(window,document)},function(t,r){t.exports=e},function(e,r){e.exports=t}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom/server")):"function"==typeof define&&define.amd?define(["react","react-dom/server"],t):"object"==typeof exports?exports.ReactSVG=t(require("react"),require("react-dom/server")):e.ReactSVG=t(e.React,e.ReactDOMServer)}(this,function(e,t){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),s=r(1),c=n(s),l=r(2),f=n(l),p=r(7),d=n(p),v="undefined"!=typeof window,h=v?r(8):void 0,y=function(e){function t(){var e,r,n,a;o(this,t);for(var u=arguments.length,s=Array(u),c=0;c<u;c++)s[c]=arguments[c];return r=n=i(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(s))),n.refCallback=function(e){if(!e)return void n.removeSVG();n.container=e,n.renderSVG()},a=r,i(n,a)}return a(t,e),u(t,[{key:"renderSVG",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props,t=e.callback,r=e.className,n=e.evalScripts,o=e.path,i=e.style,a=document.createElement("div");a.innerHTML=d.default.renderToStaticMarkup(c.default.createElement("div",null,c.default.createElement("div",{className:r,"data-src":o,style:i})));var u=this.container.appendChild(a.firstChild);h(u.firstChild,{evalScripts:n,each:t})}},{key:"removeSVG",value:function(){this.container.removeChild(this.container.firstChild)}},{key:"componentWillReceiveProps",value:function(e){this.removeSVG(),this.renderSVG(e)}},{key:"shouldComponentUpdate",value:function(){return!1}},{key:"render",value:function(){return c.default.createElement("div",{ref:this.refCallback})}}]),t}(s.Component);y.defaultProps={callback:function(){},className:"",evalScripts:"once",style:{}},y.propTypes={callback:f.default.func,className:f.default.string,evalScripts:f.default.oneOf(["always","once","never"]),path:f.default.string.isRequired,style:f.default.object},t.default=y,e.exports=t.default},function(t,r){t.exports=e},function(e,t,r){e.exports=r(3)()},function(e,t,r){"use strict";var n=r(4),o=r(5),i=r(6);e.exports=function(){function e(e,t,r,n,a,u){u!==i&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return r.checkPropTypes=n,r.PropTypes=r,r}},function(e,t,r){"use strict";function n(e){return function(){return e}}var o=function(){};o.thatReturns=n,o.thatReturnsFalse=n(!1),o.thatReturnsTrue=n(!0),o.thatReturnsNull=n(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e},e.exports=o},function(e,t,r){"use strict";function n(e,t,r,n,i,a,u,s){if(o(t),!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var l=[r,n,i,a,u,s],f=0;c=new Error(t.replace(/%s/g,function(){return l[f++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}}var o=function(e){};e.exports=n},function(e,t,r){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,r){e.exports=t},function(e,t,r){var n;/** | ||
* SVGInjector v1.1.3 - Fast, caching, dynamic inline SVG DOM injection library | ||
* https://github.com/iconic/SVGInjector | ||
* | ||
* Copyright (c) 2014-2015 Waybury <hello@waybury.com> | ||
* @license MIT | ||
*/ | ||
!function(o,i){"use strict";function a(e){e=e.split(" ");for(var t={},r=e.length,n=[];r--;)t.hasOwnProperty(e[r])||(t[e[r]]=1,n.unshift(e[r]));return n.join(" ")}var u="file:"===o.location.protocol,s=i.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1"),c=Array.prototype.forEach||function(e,t){if(void 0===this||null===this||"function"!=typeof e)throw new TypeError;var r,n=this.length>>>0;for(r=0;r<n;++r)r in this&&e.call(t,this[r],r,this)},l={},f=0,p=[],d=[],v={},h=function(e){return e.cloneNode(!0)},y=function(e,t){d[e]=d[e]||[],d[e].push(t)},m=function(e){for(var t=0,r=d[e].length;t<r;t++)!function(t){setTimeout(function(){d[e][t](h(l[e]))},0)}(t)},b=function(e,t){if(void 0!==l[e])l[e]instanceof SVGSVGElement?t(h(l[e])):y(e,t);else{if(!o.XMLHttpRequest)return t("Browser does not support XMLHttpRequest"),!1;l[e]={},y(e,t);var r=new XMLHttpRequest;r.onreadystatechange=function(){if(4===r.readyState){if(404===r.status||null===r.responseXML)return t("Unable to load SVG file: "+e),u&&t("Note: SVG injection ajax calls do not work locally without adjusting security setting in your browser. Or consider using a local webserver."),t(),!1;if(!(200===r.status||u&&0===r.status))return t("There was a problem injecting the SVG: "+r.status+" "+r.statusText),!1;if(r.responseXML instanceof Document)l[e]=r.responseXML.documentElement;else if(DOMParser&&DOMParser instanceof Function){var n;try{var o=new DOMParser;n=o.parseFromString(r.responseText,"text/xml")}catch(e){n=void 0}if(!n||n.getElementsByTagName("parsererror").length)return t("Unable to parse SVG file: "+e),!1;l[e]=n.documentElement}m(e)}},r.open("GET",e),r.overrideMimeType&&r.overrideMimeType("text/xml"),r.send()}},g=function(e,t,r,n){var i=e.getAttribute("data-src")||e.getAttribute("src");if(!/\.svg/i.test(i))return void n("Attempted to inject a file with a non-svg extension: "+i);if(!s){var u=e.getAttribute("data-fallback")||e.getAttribute("data-png");return void(u?(e.setAttribute("src",u),n(null)):r?(e.setAttribute("src",r+"/"+i.split("/").pop().replace(".svg",".png")),n(null)):n("This browser does not support SVG and no PNG fallback was defined."))}-1===p.indexOf(e)&&(p.push(e),e.setAttribute("src",""),b(i,function(r){if(void 0===r||"string"==typeof r)return n(r),!1;var u=e.getAttribute("id");u&&r.setAttribute("id",u);var s=e.getAttribute("title");s&&r.setAttribute("title",s);var l=[].concat(r.getAttribute("class")||[],"injected-svg",e.getAttribute("class")||[]).join(" ");r.setAttribute("class",a(l));var d=e.getAttribute("style");d&&r.setAttribute("style",d);var h=[].filter.call(e.attributes,function(e){return/^data-\w[\w\-]*$/.test(e.name)});c.call(h,function(e){e.name&&e.value&&r.setAttribute(e.name,e.value)});var y,m,b,g,w,x={clipPath:["clip-path"],"color-profile":["color-profile"],cursor:["cursor"],filter:["filter"],linearGradient:["fill","stroke"],marker:["marker","marker-start","marker-mid","marker-end"],mask:["mask"],pattern:["fill","stroke"],radialGradient:["fill","stroke"]};Object.keys(x).forEach(function(e){y=e,b=x[e],m=r.querySelectorAll("defs "+y+"[id]");for(var t=0,n=m.length;t<n;t++){g=m[t].id,w=g+"-"+f;var o;c.call(b,function(e){o=r.querySelectorAll("["+e+'*="'+g+'"]');for(var t=0,n=o.length;t<n;t++)o[t].setAttribute(e,"url(#"+w+")")}),m[t].id=w}}),r.removeAttribute("xmlns:a");for(var S,k,O=r.querySelectorAll("script"),A=[],T=0,j=O.length;T<j;T++)(k=O[T].getAttribute("type"))&&"application/ecmascript"!==k&&"application/javascript"!==k||(S=O[T].innerText||O[T].textContent,A.push(S),r.removeChild(O[T]));if(A.length>0&&("always"===t||"once"===t&&!v[i])){for(var _=0,P=A.length;_<P;_++)new Function(A[_])(o);v[i]=!0}var R=r.querySelectorAll("style");c.call(R,function(e){e.textContent+=""}),e.parentNode.replaceChild(r,e),delete p[p.indexOf(e)],e=null,f++,n(r)}))},w=function(e,t,r){t=t||{};var n=t.evalScripts||"always",o=t.pngFallback||!1,i=t.each;if(void 0!==e.length){var a=0;c.call(e,function(t){g(t,n,o,function(t){i&&"function"==typeof i&&i(t),r&&e.length===++a&&r(a)})})}else e?g(e,n,o,function(t){i&&"function"==typeof i&&i(t),r&&r(1),e=null}):r&&r(0)};"object"==typeof e&&"object"==typeof e.exports?e.exports=t=w:void 0!==(n=function(){return w}.call(t,r,t,e))&&(e.exports=n)}(window,document)}])}); |
@@ -1,5 +0,5 @@ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom' | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import ReactSVG from '../src' | ||
import ReactSVG from '../src'; | ||
@@ -13,2 +13,2 @@ ReactDOM.render( | ||
document.querySelector('.Root') | ||
) | ||
); |
@@ -73,7 +73,3 @@ 'use strict'; | ||
null, | ||
_react2.default.createElement('div', { | ||
className: className, | ||
'data-src': path, | ||
style: style | ||
}) | ||
_react2.default.createElement('div', { className: className, 'data-src': path, style: style }) | ||
)); | ||
@@ -80,0 +76,0 @@ |
{ | ||
"name": "react-svg", | ||
"version": "2.1.21", | ||
"version": "2.1.22", | ||
"description": "A react.js svg component for loading svg files into the dom.", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"precommit": "lint-staged", | ||
"clean": "rimraf dist lib", | ||
"lint": "eslint .", | ||
"test": "jest && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js || true", | ||
@@ -15,3 +15,3 @@ "start": "babel-node ./bin/start.js", | ||
"build": "npm run clean && npm run build:lib && npm run build:umd && npm run build:umd:min", | ||
"preversion": "npm run lint && npm test", | ||
"preversion": "npm test", | ||
"version": "npm run build", | ||
@@ -21,2 +21,8 @@ "postversion": "git push && git push --tags && npm publish", | ||
}, | ||
"lint-staged": { | ||
"*.js": [ | ||
"eslint --fix", | ||
"git add" | ||
] | ||
}, | ||
"repository": { | ||
@@ -38,4 +44,4 @@ "type": "git", | ||
"peerDependencies": { | ||
"react": "^15.5.4", | ||
"react-dom": "^15.5.4" | ||
"react": "^15.5.4 || ^16.0.0", | ||
"react-dom": "^15.5.4 || ^16.0.0" | ||
}, | ||
@@ -47,23 +53,29 @@ "dependencies": { | ||
"babel-cli": "^6.16.0", | ||
"babel-eslint": "^7.1.1", | ||
"babel-jest": "^18.0.0", | ||
"babel-loader": "^6.2.5", | ||
"babel-eslint": "^8.0.1", | ||
"babel-jest": "^21.2.0", | ||
"babel-loader": "^7.1.2", | ||
"babel-plugin-add-module-exports": "^0.2.1", | ||
"babel-preset-es2015": "^6.18.0", | ||
"babel-preset-env": "1.6.0", | ||
"babel-preset-react": "^6.16.0", | ||
"babel-preset-stage-1": "^6.16.0", | ||
"coveralls": "^2.11.15", | ||
"enzyme": "^2.8.2", | ||
"eslint": "^3.8.0", | ||
"eslint-config-rackt": "^1.1.1", | ||
"eslint-plugin-react": "^6.4.1", | ||
"jest": "^18.1.0", | ||
"coveralls": "^3.0.0", | ||
"enzyme": "^3.0.0", | ||
"enzyme-adapter-react-16": "1.0.0", | ||
"eslint": "^4.7.2", | ||
"eslint-config-prettier": "2.6.0", | ||
"eslint-plugin-prettier": "2.3.1", | ||
"eslint-plugin-react": "^7.4.0", | ||
"husky": "0.14.3", | ||
"jest": "^21.2.1", | ||
"lint-staged": "4.2.3", | ||
"prettier": "1.7.3", | ||
"prop-types": "^15.5.10", | ||
"react": "^15.5.4", | ||
"react-dom": "^15.5.4", | ||
"react-test-renderer": "^15.5.4", | ||
"raf": "^3.3.2", | ||
"react": "^16.0.0", | ||
"react-dom": "^16.0.0", | ||
"react-test-renderer": "^16.0.0", | ||
"rimraf": "^2.5.4", | ||
"sinon": "^1.17.7", | ||
"webpack": "^1.13.2", | ||
"webpack-dev-server": "^1.16.2" | ||
"sinon": "^4.0.0", | ||
"webpack": "^3.6.0", | ||
"webpack-dev-server": "^2.9.1" | ||
}, | ||
@@ -78,5 +90,6 @@ "jest": { | ||
"setupFiles": [ | ||
"raf/polyfill", | ||
"<rootDir>/.jest-setup.js" | ||
], | ||
"testPathDirs": [ | ||
"roots": [ | ||
"test" | ||
@@ -83,0 +96,0 @@ ] |
@@ -13,5 +13,5 @@ # react-svg | ||
```js | ||
import React from 'react' | ||
import ReactDOM from 'react-dom' | ||
import ReactSVG from 'react-svg' | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import ReactSVG from 'react-svg'; | ||
@@ -25,3 +25,3 @@ ReactDOM.render( | ||
document.querySelector('.Root') | ||
) | ||
); | ||
``` | ||
@@ -46,6 +46,6 @@ | ||
path="atomic.svg" | ||
callback={(svg) => console.log(svg)} | ||
callback={svg => console.log(svg)} | ||
className="example" | ||
evalScript="always" | ||
style={{ width: 200 }} | ||
style={{width: 200}} | ||
/> | ||
@@ -52,0 +52,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
52935
895
28