Merge pull request #167 from jgoz/weakset-ie11

Avoid crash if WeakSet is not available
This commit is contained in:
Brian Vaughn
2019-03-08 07:59:21 -08:00
committed by GitHub
2 changed files with 16 additions and 12 deletions
+8 -6
View File
@@ -132,8 +132,10 @@ const defaultItemKey = ({ columnIndex, data, rowIndex }) =>
let devWarningsOverscanCount = null;
let devWarningsTagName = null;
if (process.env.NODE_ENV !== 'production') {
devWarningsOverscanCount = new WeakSet();
devWarningsTagName = new WeakSet();
if (typeof window.WeakSet !== 'undefined') {
devWarningsOverscanCount = new WeakSet();
devWarningsTagName = new WeakSet();
}
}
export default function createGridComponent({
@@ -746,8 +748,8 @@ const validateSharedProps = (
): void => {
if (process.env.NODE_ENV !== 'production') {
if (typeof overscanCount === 'number') {
if (!((devWarningsOverscanCount: any): WeakSet<any>).has(instance)) {
((devWarningsOverscanCount: any): WeakSet<any>).add(instance);
if (devWarningsOverscanCount && !devWarningsOverscanCount.has(instance)) {
devWarningsOverscanCount.add(instance);
console.warn(
'The overscanCount prop has been deprecated. ' +
'Please use the overscanColumnsCount and overscanRowsCount props instead.'
@@ -756,8 +758,8 @@ const validateSharedProps = (
}
if (innerTagName != null || outerTagName != null) {
if (!((devWarningsTagName: any): WeakSet<any>).has(instance)) {
((devWarningsTagName: any): WeakSet<any>).add(instance);
if (devWarningsTagName && !devWarningsTagName.has(instance)) {
devWarningsTagName.add(instance);
console.warn(
'The innerTagName and outerTagName props have been deprecated. ' +
'Please use the innerElementType and outerElementType props instead.'
+8 -6
View File
@@ -112,8 +112,10 @@ const defaultItemKey = (index: number, data: any) => index;
let devWarningsDirection = null;
let devWarningsTagName = null;
if (process.env.NODE_ENV !== 'production') {
devWarningsDirection = new WeakSet();
devWarningsTagName = new WeakSet();
if (typeof window.WeakSet !== 'undefined') {
devWarningsDirection = new WeakSet();
devWarningsTagName = new WeakSet();
}
}
export default function createListComponent({
@@ -587,8 +589,8 @@ const validateSharedProps = (
): void => {
if (process.env.NODE_ENV !== 'production') {
if (innerTagName != null || outerTagName != null) {
if (!((devWarningsTagName: any): WeakSet<any>).has(instance)) {
((devWarningsTagName: any): WeakSet<any>).add(instance);
if (devWarningsTagName && !devWarningsTagName.has(instance)) {
devWarningsTagName.add(instance);
console.warn(
'The innerTagName and outerTagName props have been deprecated. ' +
'Please use the innerElementType and outerElementType props instead.'
@@ -602,8 +604,8 @@ const validateSharedProps = (
switch (direction) {
case 'horizontal':
case 'vertical':
if (!((devWarningsDirection: any): WeakSet<any>).has(instance)) {
((devWarningsDirection: any): WeakSet<any>).add(instance);
if (devWarningsDirection && !devWarningsDirection.has(instance)) {
devWarningsDirection.add(instance);
console.warn(
'The direction prop should be either "ltr" (default) or "rtl". ' +
'Please use the layout prop to specify "vertical" (default) or "horizontal" orientation.'