Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-meta-tags

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-meta-tags - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

230

dist/react-meta-tags.es.js
/**
* react-meta-tags - 0.7.4
* react-meta-tags - 1.0.1
* Author : Sudhanshu Yadav
* Copyright (c) 2016, 2019 to Sudhanshu Yadav, released under the MIT license.
* Copyright (c) 2016, 2020 to Sudhanshu Yadav, released under the MIT license.
* https://github.com/s-yadav/react-meta-tags
*/
import React, { Component, Children } from 'react';
import React, { Component, Children, createContext } from 'react';
import ReactDOM from 'react-dom';

@@ -95,202 +95,30 @@

function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
/* eslint-disable no-unused-vars */
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
var hasOwnProperty = Object.prototype.hasOwnProperty;
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
function toObject(val) {
if (val === null || val === undefined) {
throw new TypeError('Object.assign cannot be called with null or undefined');
}
return Object(val);
}
function shouldUseNative() {
try {
if (!Object.assign) {
return false;
}
// Detect buggy property enumeration order in older V8 versions.
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
test1[5] = 'de';
if (Object.getOwnPropertyNames(test1)[0] === '5') {
return false;
}
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test2 = {};
for (var i = 0; i < 10; i++) {
test2['_' + String.fromCharCode(i)] = i;
}
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
return test2[n];
});
if (order2.join('') !== '0123456789') {
return false;
}
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test3 = {};
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
test3[letter] = letter;
});
if (Object.keys(Object.assign({}, test3)).join('') !==
'abcdefghijklmnopqrst') {
return false;
}
return true;
} catch (err) {
// We don't expect any of the above to throw, but better to be safe.
return false;
}
}
var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
var from;
var to = toObject(target);
var symbols;
for (var s = 1; s < arguments.length; s++) {
from = Object(arguments[s]);
for (var key in from) {
if (hasOwnProperty.call(from, key)) {
to[key] = from[key];
}
}
if (getOwnPropertySymbols) {
symbols = getOwnPropertySymbols(from);
for (var i = 0; i < symbols.length; i++) {
if (propIsEnumerable.call(from, symbols[i])) {
to[symbols[i]] = from[symbols[i]];
}
}
}
}
return to;
};
/**
* 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.
*/
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
var ReactPropTypesSecret_1 = ReactPropTypesSecret;
function emptyFunction() {}
var factoryWithThrowingShims = function() {
function shim(props, propName, componentName, location, propFullName, secret) {
if (secret === ReactPropTypesSecret_1) {
// It is still safe when called from React.
return;
}
var err = new Error(
'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'
);
err.name = 'Invariant Violation';
throw err;
} 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,
any: shim,
arrayOf: getShim,
element: shim,
instanceOf: getShim,
node: shim,
objectOf: getShim,
oneOf: getShim,
oneOfType: getShim,
shape: getShim,
exact: getShim
};
ReactPropTypes.checkPropTypes = emptyFunction;
ReactPropTypes.PropTypes = ReactPropTypes;
return ReactPropTypes;
};
var propTypes = createCommonjsModule(function (module) {
/**
* 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.
*/
{
// By explicitly using `prop-types` you are opting into new production behavior.
// http://fb.me/prop-types-in-prod
module.exports = factoryWithThrowingShims();
}
});
var MetaContext = createContext({});
/** context class which passes extract fuunction to MetaTags Component **/
var MetaTagsContext =
var MetaContextProviderWrapper =
/*#__PURE__*/
function (_Component) {
_inherits(MetaTagsContext, _Component);
_inherits(MetaContextProviderWrapper, _Component);
function MetaTagsContext() {
_classCallCheck(this, MetaTagsContext);
function MetaContextProviderWrapper() {
_classCallCheck(this, MetaContextProviderWrapper);
return _possibleConstructorReturn(this, _getPrototypeOf(MetaTagsContext).apply(this, arguments));
return _possibleConstructorReturn(this, _getPrototypeOf(MetaContextProviderWrapper).apply(this, arguments));
}
_createClass(MetaTagsContext, [{
key: "getChildContext",
value: function getChildContext() {
return {
extract: this.props.extract
};
}
}, {
_createClass(MetaContextProviderWrapper, [{
key: "render",
value: function render() {
return Children.only(this.props.children);
return React.createElement(MetaContext.Provider, {
value: {
extract: this.props.extract
}
}, Children.only(this.props.children));
}
}]);
return MetaTagsContext;
return MetaContextProviderWrapper;
}(Component);
_defineProperty(MetaTagsContext, "childContextTypes", {
extract: propTypes.func
});
var uniqueIdentifiersI = ['property', 'name', 'itemprop'];

@@ -317,11 +145,9 @@ /**

}
function getDuplicateElementById(_ref) {
var id = _ref.id;
return id && document.head.querySelector("#".concat(id));
}
function getDuplicateMeta(meta) {
var head = document.head;
var id = meta.id; //if has id and element with id is not present than return the element
var head = document.head; //for any other unique identifier check if metas already available with same identifier which doesn't have id
if (id) {
return id && head.querySelector("#".concat(id));
} //for any other unique identifier check if metas already available with same identifier which doesn't have id
return uniqueIdentifiersI.reduce(function (duplicates, identifier) {

@@ -446,2 +272,6 @@ var identifierValue = meta.getAttribute(identifier);

if (title) removeChild(head, title);
} else if (child.id) {
// if the element has id defined remove the existing element with that id
var elm = getDuplicateElementById(child);
if (elm) removeChild(head, elm);
} else if (tag === 'meta') {

@@ -469,5 +299,3 @@ var meta = getDuplicateMeta(child);

_defineProperty(MetaTags, "contextTypes", {
extract: propTypes.func
});
_defineProperty(MetaTags, "contextType", MetaContext);

@@ -495,7 +323,3 @@ var ReactTitle =

_defineProperty(ReactTitle, "propTypes", {
title: propTypes.string
});
export default MetaTags;
export { MetaTags, MetaTagsContext, ReactTitle };
export { MetaTags, MetaContextProviderWrapper as MetaTagsContext, ReactTitle };
/**
* react-meta-tags - 0.7.4
* react-meta-tags - 1.0.1
* Author : Sudhanshu Yadav
* Copyright (c) 2016, 2019 to Sudhanshu Yadav, released under the MIT license.
* Copyright (c) 2016, 2020 to Sudhanshu Yadav, released under the MIT license.
* https://github.com/s-yadav/react-meta-tags

@@ -101,202 +101,30 @@ */

function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
/* eslint-disable no-unused-vars */
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
var hasOwnProperty = Object.prototype.hasOwnProperty;
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
function toObject(val) {
if (val === null || val === undefined) {
throw new TypeError('Object.assign cannot be called with null or undefined');
}
return Object(val);
}
function shouldUseNative() {
try {
if (!Object.assign) {
return false;
}
// Detect buggy property enumeration order in older V8 versions.
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
test1[5] = 'de';
if (Object.getOwnPropertyNames(test1)[0] === '5') {
return false;
}
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test2 = {};
for (var i = 0; i < 10; i++) {
test2['_' + String.fromCharCode(i)] = i;
}
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
return test2[n];
});
if (order2.join('') !== '0123456789') {
return false;
}
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test3 = {};
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
test3[letter] = letter;
});
if (Object.keys(Object.assign({}, test3)).join('') !==
'abcdefghijklmnopqrst') {
return false;
}
return true;
} catch (err) {
// We don't expect any of the above to throw, but better to be safe.
return false;
}
}
var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
var from;
var to = toObject(target);
var symbols;
for (var s = 1; s < arguments.length; s++) {
from = Object(arguments[s]);
for (var key in from) {
if (hasOwnProperty.call(from, key)) {
to[key] = from[key];
}
}
if (getOwnPropertySymbols) {
symbols = getOwnPropertySymbols(from);
for (var i = 0; i < symbols.length; i++) {
if (propIsEnumerable.call(from, symbols[i])) {
to[symbols[i]] = from[symbols[i]];
}
}
}
}
return to;
};
/**
* 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.
*/
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
var ReactPropTypesSecret_1 = ReactPropTypesSecret;
function emptyFunction() {}
var factoryWithThrowingShims = function() {
function shim(props, propName, componentName, location, propFullName, secret) {
if (secret === ReactPropTypesSecret_1) {
// It is still safe when called from React.
return;
}
var err = new Error(
'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'
);
err.name = 'Invariant Violation';
throw err;
} 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,
any: shim,
arrayOf: getShim,
element: shim,
instanceOf: getShim,
node: shim,
objectOf: getShim,
oneOf: getShim,
oneOfType: getShim,
shape: getShim,
exact: getShim
};
ReactPropTypes.checkPropTypes = emptyFunction;
ReactPropTypes.PropTypes = ReactPropTypes;
return ReactPropTypes;
};
var propTypes = createCommonjsModule(function (module) {
/**
* 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.
*/
{
// By explicitly using `prop-types` you are opting into new production behavior.
// http://fb.me/prop-types-in-prod
module.exports = factoryWithThrowingShims();
}
});
var MetaContext = React.createContext({});
/** context class which passes extract fuunction to MetaTags Component **/
var MetaTagsContext =
var MetaContextProviderWrapper =
/*#__PURE__*/
function (_Component) {
_inherits(MetaTagsContext, _Component);
_inherits(MetaContextProviderWrapper, _Component);
function MetaTagsContext() {
_classCallCheck(this, MetaTagsContext);
function MetaContextProviderWrapper() {
_classCallCheck(this, MetaContextProviderWrapper);
return _possibleConstructorReturn(this, _getPrototypeOf(MetaTagsContext).apply(this, arguments));
return _possibleConstructorReturn(this, _getPrototypeOf(MetaContextProviderWrapper).apply(this, arguments));
}
_createClass(MetaTagsContext, [{
key: "getChildContext",
value: function getChildContext() {
return {
extract: this.props.extract
};
}
}, {
_createClass(MetaContextProviderWrapper, [{
key: "render",
value: function render() {
return React.Children.only(this.props.children);
return React__default.createElement(MetaContext.Provider, {
value: {
extract: this.props.extract
}
}, React.Children.only(this.props.children));
}
}]);
return MetaTagsContext;
return MetaContextProviderWrapper;
}(React.Component);
_defineProperty(MetaTagsContext, "childContextTypes", {
extract: propTypes.func
});
var uniqueIdentifiersI = ['property', 'name', 'itemprop'];

@@ -323,11 +151,9 @@ /**

}
function getDuplicateElementById(_ref) {
var id = _ref.id;
return id && document.head.querySelector("#".concat(id));
}
function getDuplicateMeta(meta) {
var head = document.head;
var id = meta.id; //if has id and element with id is not present than return the element
var head = document.head; //for any other unique identifier check if metas already available with same identifier which doesn't have id
if (id) {
return id && head.querySelector("#".concat(id));
} //for any other unique identifier check if metas already available with same identifier which doesn't have id
return uniqueIdentifiersI.reduce(function (duplicates, identifier) {

@@ -452,2 +278,6 @@ var identifierValue = meta.getAttribute(identifier);

if (title) removeChild(head, title);
} else if (child.id) {
// if the element has id defined remove the existing element with that id
var elm = getDuplicateElementById(child);
if (elm) removeChild(head, elm);
} else if (tag === 'meta') {

@@ -475,5 +305,3 @@ var meta = getDuplicateMeta(child);

_defineProperty(MetaTags, "contextTypes", {
extract: propTypes.func
});
_defineProperty(MetaTags, "contextType", MetaContext);

@@ -501,9 +329,5 @@ var ReactTitle =

_defineProperty(ReactTitle, "propTypes", {
title: propTypes.string
});
exports.default = MetaTags;
exports.MetaTags = MetaTags;
exports.MetaTagsContext = MetaTagsContext;
exports.MetaTagsContext = MetaContextProviderWrapper;
exports.ReactTitle = ReactTitle;

@@ -510,0 +334,0 @@

6

dist/react-meta-tags.min.js
/**
* react-meta-tags - 0.7.4
* react-meta-tags - 1.0.1
* Author : Sudhanshu Yadav
* Copyright (c) 2016, 2019 to Sudhanshu Yadav, released under the MIT license.
* Copyright (c) 2016, 2020 to Sudhanshu Yadav, released under the MIT license.
* https://github.com/s-yadav/react-meta-tags
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],t):t(e.MetaTags={},e.React,e.ReactDOM)}(this,function(e,n,r){"use strict";var i="default"in n?n.default:n;function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),e}function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&p(e,t)}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function p(e,t){return(p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}r=r&&r.hasOwnProperty("default")?r.default:r;var s=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable;(function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}})()&&Object.assign;function y(){}var m,v=(function(e){e.exports=function(){function e(e,t,n,r,o,i){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==i){var a=new Error("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");throw a.name="Invariant Violation",a}}function t(){return e}var n={array:e.isRequired=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 n.checkPropTypes=y,n.PropTypes=n}()}(m={exports:{}},m.exports),m.exports),b=function(e){function t(){return o(this,t),f(this,l(t).apply(this,arguments))}return u(t,n.Component),c(t,[{key:"getChildContext",value:function(){return{extract:this.props.extract}}},{key:"render",value:function(){return n.Children.only(this.props.children)}}]),t}();t(b,"childContextTypes",{extract:v.func});var O=["property","name","itemprop"];function g(o){var i=document.head,e=o.id;return e?e&&i.querySelector("#".concat(e)):O.reduce(function(e,t){var n,r=o.getAttribute(t);return r?e.concat((n=i.querySelectorAll("[".concat(t,' = "').concat(r,'"]')),(n=Array.prototype.slice.call(n||[])).filter(function(e){return!e.id}))):e},[])}function j(e,t){void 0===t.length&&(t=[t]);for(var n=0,r=t.length;n<r;n++)e.removeChild(t[n])}var C=function(e){function t(){return o(this,t),f(this,l(t).apply(this,arguments))}return u(t,n.Component),c(t,[{key:"componentDidMount",value:function(){this.temporaryElement=document.createElement("div"),this.handleChildrens()}},{key:"componentDidUpdate",value:function(e){e.children!==this.props.children&&this.handleChildrens()}},{key:"componentWillUnmount",value:function(){this.temporaryElement&&r.unmountComponentAtNode(this.temporaryElement)}},{key:"extractChildren",value:function(){var e=this.context.extract,t=this.props.children;t&&e&&e(t)}},{key:"handleChildrens",value:function(){var o=this,e=this.props.children;if(!this.context.extract&&e){var t=i.createElement("div",{className:"react-head-temp"},e);r.render(t,this.temporaryElement,function(){var e=o.temporaryElement.innerHTML;if(o.lastChildStr!==e){o.lastChildStr=e;var t=o.temporaryElement.querySelector(".react-head-temp");if(null!==t){var n=Array.prototype.slice.call(t.children),i=document.head,r=i.innerHTML;(n=(n=n.filter(function(e){return-1===r.indexOf(e.outerHTML)})).map(function(e){return e.cloneNode(!0)})).forEach(function(e){var t=e.tagName.toLowerCase();if("title"===t){var n=document.head.querySelectorAll("title");n&&j(i,n)}else if("meta"===t){var r=g(e);r&&j(i,r)}else if("link"===t&&"canonical"===e.rel){var o=document.head.querySelectorAll('link[rel="canonical"]');o&&j(i,o)}}),function(e,t){void 0===t.length&&(t=[t]);for(var n=document.createDocumentFragment(),r=0,o=t.length;r<o;r++)n.appendChild(t[r]);e.appendChild(n)}(document.head,n)}}})}}},{key:"render",value:function(){return this.extractChildren(),null}}]),t}();t(C,"contextTypes",{extract:v.func});var x=function(e){function t(){return o(this,t),f(this,l(t).apply(this,arguments))}return u(t,n.Component),c(t,[{key:"render",value:function(){return i.createElement(C,null,i.createElement("title",null,this.props.title))}}]),t}();t(x,"propTypes",{title:v.string}),e.default=C,e.MetaTags=C,e.MetaTagsContext=b,e.ReactTitle=x,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],t):t(e.MetaTags={},e.React,e.ReactDOM)}(this,function(e,n,r){"use strict";var i="default"in n?n.default:n;function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),e}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&f(e,t)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}r=r&&r.hasOwnProperty("default")?r.default:r;var p=n.createContext({}),t=function(e){function t(){return o(this,t),d(this,u(t).apply(this,arguments))}return l(t,n.Component),c(t,[{key:"render",value:function(){return i.createElement(p.Provider,{value:{extract:this.props.extract}},n.Children.only(this.props.children))}}]),t}(),s=["property","name","itemprop"];function h(o){var i=document.head;return s.reduce(function(e,t){var n,r=o.getAttribute(t);return r?e.concat((n=i.querySelectorAll("[".concat(t,' = "').concat(r,'"]')),(n=Array.prototype.slice.call(n||[])).filter(function(e){return!e.id}))):e},[])}function m(e,t){void 0===t.length&&(t=[t]);for(var n=0,r=t.length;n<r;n++)e.removeChild(t[n])}var y,v,b,C=function(e){function t(){return o(this,t),d(this,u(t).apply(this,arguments))}return l(t,n.Component),c(t,[{key:"componentDidMount",value:function(){this.temporaryElement=document.createElement("div"),this.handleChildrens()}},{key:"componentDidUpdate",value:function(e){e.children!==this.props.children&&this.handleChildrens()}},{key:"componentWillUnmount",value:function(){this.temporaryElement&&r.unmountComponentAtNode(this.temporaryElement)}},{key:"extractChildren",value:function(){var e=this.context.extract,t=this.props.children;t&&e&&e(t)}},{key:"handleChildrens",value:function(){var o=this,e=this.props.children;if(!this.context.extract&&e){var t=i.createElement("div",{className:"react-head-temp"},e);r.render(t,this.temporaryElement,function(){var e=o.temporaryElement.innerHTML;if(o.lastChildStr!==e){o.lastChildStr=e;var t=o.temporaryElement.querySelector(".react-head-temp");if(null!==t){var n=Array.prototype.slice.call(t.children),c=document.head,r=c.innerHTML;(n=(n=n.filter(function(e){return-1===r.indexOf(e.outerHTML)})).map(function(e){return e.cloneNode(!0)})).forEach(function(e){var t,n=e.tagName.toLowerCase();if("title"===n){var r=document.head.querySelectorAll("title");r&&m(c,r)}else if(e.id){var o=(t=e.id)&&document.head.querySelector("#".concat(t));o&&m(c,o)}else if("meta"===n){var i=h(e);i&&m(c,i)}else if("link"===n&&"canonical"===e.rel){var a=document.head.querySelectorAll('link[rel="canonical"]');a&&m(c,a)}}),function(e,t){void 0===t.length&&(t=[t]);for(var n=document.createDocumentFragment(),r=0,o=t.length;r<o;r++)n.appendChild(t[r]);e.appendChild(n)}(document.head,n)}}})}}},{key:"render",value:function(){return this.extractChildren(),null}}]),t}();b=p,(v="contextType")in(y=C)?Object.defineProperty(y,v,{value:b,enumerable:!0,configurable:!0,writable:!0}):y[v]=b;var g=function(e){function t(){return o(this,t),d(this,u(t).apply(this,arguments))}return l(t,n.Component),c(t,[{key:"render",value:function(){return i.createElement(C,null,i.createElement("title",null,this.props.title))}}]),t}();e.default=C,e.MetaTags=C,e.MetaTagsContext=t,e.ReactTitle=g,Object.defineProperty(e,"__esModule",{value:!0})});

@@ -6,10 +6,8 @@ "use strict";

});
exports.default = void 0;
exports.default = exports.MetaContext = void 0;
var _react = require("react");
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

@@ -33,39 +31,33 @@

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var MetaContext = (0, _react.createContext)({});
/** context class which passes extract fuunction to MetaTags Component **/
/** context class which passes extract fuunction to MetaTags Component **/
var MetaTagsContext =
exports.MetaContext = MetaContext;
var MetaContextProviderWrapper =
/*#__PURE__*/
function (_Component) {
_inherits(MetaTagsContext, _Component);
_inherits(MetaContextProviderWrapper, _Component);
function MetaTagsContext() {
_classCallCheck(this, MetaTagsContext);
function MetaContextProviderWrapper() {
_classCallCheck(this, MetaContextProviderWrapper);
return _possibleConstructorReturn(this, _getPrototypeOf(MetaTagsContext).apply(this, arguments));
return _possibleConstructorReturn(this, _getPrototypeOf(MetaContextProviderWrapper).apply(this, arguments));
}
_createClass(MetaTagsContext, [{
key: "getChildContext",
value: function getChildContext() {
return {
extract: this.props.extract
};
}
}, {
_createClass(MetaContextProviderWrapper, [{
key: "render",
value: function render() {
return _react.Children.only(this.props.children);
return _react.default.createElement(MetaContext.Provider, {
value: {
extract: this.props.extract
}
}, _react.Children.only(this.props.children));
}
}]);
return MetaTagsContext;
return MetaContextProviderWrapper;
}(_react.Component);
_defineProperty(MetaTagsContext, "childContextTypes", {
extract: _propTypes.default.func
});
var _default = MetaTagsContext;
exports.default = _default;
module.exports = exports.default;
var _default = MetaContextProviderWrapper;
exports.default = _default;

@@ -10,4 +10,2 @@ "use strict";

var _propTypes = _interopRequireDefault(require("prop-types"));
var _reactDom = _interopRequireDefault(require("react-dom"));

@@ -17,2 +15,4 @@

var _meta_tags_context = require("./meta_tags_context");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -137,2 +137,6 @@

if (title) (0, _utils.removeChild)(head, title);
} else if (child.id) {
// if the element has id defined remove the existing element with that id
var elm = (0, _utils.getDuplicateElementById)(child);
if (elm) (0, _utils.removeChild)(head, elm);
} else if (tag === 'meta') {

@@ -160,5 +164,3 @@ var meta = (0, _utils.getDuplicateMeta)(child);

_defineProperty(MetaTags, "contextTypes", {
extract: _propTypes.default.func
});
_defineProperty(MetaTags, "contextType", _meta_tags_context.MetaContext);

@@ -165,0 +167,0 @@ var _default = MetaTags;

@@ -10,4 +10,2 @@ "use strict";

var _propTypes = _interopRequireDefault(require("prop-types"));
var _meta_tags = _interopRequireDefault(require("./meta_tags"));

@@ -37,4 +35,2 @@

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var ReactTitle =

@@ -61,8 +57,4 @@ /*#__PURE__*/

_defineProperty(ReactTitle, "propTypes", {
title: _propTypes.default.string
});
var _default = ReactTitle;
exports.default = _default;
module.exports = exports.default;

@@ -9,2 +9,3 @@ "use strict";

exports.getDuplicateCanonical = getDuplicateCanonical;
exports.getDuplicateElementById = getDuplicateElementById;
exports.getDuplicateMeta = getDuplicateMeta;

@@ -42,6 +43,6 @@ exports.appendChild = appendChild;

function filterAndArrangeTags(headElms) {
var title = null,
canonicalLink = null;
var metas = [],
rest = [];
var title = null;
var canonicalLink = null;
var metas = [];
var rest = [];
headElms.forEach(function (elm) {

@@ -88,3 +89,3 @@ var type = elm.type,

if (addMeta) {
filteredMetas.unshift(meta); //add meta as added
filteredMetas.unshift(meta); //add meta as added

@@ -113,11 +114,10 @@ uniqueIdentifiersAll.forEach(function (identifier) {

function getDuplicateElementById(_ref) {
var id = _ref.id;
return id && document.head.querySelector("#".concat(id));
}
function getDuplicateMeta(meta) {
var head = document.head;
var id = meta.id; //if has id and element with id is not present than return the element
var head = document.head; //for any other unique identifier check if metas already available with same identifier which doesn't have id
if (id) {
return id && head.querySelector("#".concat(id));
} //for any other unique identifier check if metas already available with same identifier which doesn't have id
return uniqueIdentifiersI.reduce(function (duplicates, identifier) {

@@ -124,0 +124,0 @@ var identifierValue = meta.getAttribute(identifier);

{
"name": "react-meta-tags",
"description": "Handle document meta/head tags in isomorphic react with ease.",
"version": "1.0.0",
"version": "1.0.1",
"main": "lib/index.js",

@@ -6,0 +6,0 @@ "author": "Sudhanshu Yadav",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc