Skip to content

Commit 4b6fc1d

Browse files
author
Bond
committed
0.4.0
1 parent 7ef817d commit 4b6fc1d

3 files changed

Lines changed: 117 additions & 21 deletions

File tree

dist/react-static-google-map.cjs.js

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,22 @@ function locationBuilder(location) {
284284
return urlParts.join('%7C'); // |
285285
}
286286

287+
function isStatelessComponent(component) {
288+
return !component.render && !(component.prototype && component.prototype.render);
289+
}
290+
291+
function isClassComponent(component) {
292+
return Boolean(component && component.prototype.isReactComponent && component.prototype.render);
293+
}
294+
295+
function renderStatelessComponent(component, props) {
296+
return component(props);
297+
}
298+
299+
function renderClassComponent(component, props) {
300+
return new component(props).render();
301+
}
302+
287303
var markerStrategy = function markerStrategy(_ref, parentProps) {
288304
var props = _ref.props;
289305
var size = props.size,
@@ -572,19 +588,35 @@ var StaticGoogleMap = function (_Component) {
572588
createClass(StaticGoogleMap, [{
573589
key: 'buildParts',
574590
value: function buildParts(children, props) {
575-
return React__default.Children.map(children, function (Child) {
576-
switch (Child.type.name) {
591+
var _this2 = this;
592+
593+
return React__default.Children.map(children, function (child) {
594+
if (!React__default.isValidElement(child)) {
595+
return null;
596+
}
597+
598+
switch (child.type.name) {
577599
case 'Marker':
578-
return markerStrategy(Child, props);
600+
return markerStrategy(child, props);
579601
case 'MarkerGroup':
580-
return markerGroupStrategy(Child, props);
602+
return markerGroupStrategy(child, props);
581603
case 'Path':
582-
return pathStrategy(Child, props);
604+
return pathStrategy(child, props);
583605
case 'PathGroup':
584-
return pathGroupStrategy(Child, props);
606+
return pathGroupStrategy(child, props);
585607
case 'Direction':
586-
return directionStrategy(Child, props);
608+
return directionStrategy(child, props);
587609
default:
610+
var componentType = child.type;
611+
612+
if (isStatelessComponent(componentType)) {
613+
return _this2.buildParts(renderStatelessComponent(componentType, _extends({}, child.props)), props);
614+
}
615+
616+
if (isClassComponent(componentType)) {
617+
return _this2.buildParts(renderClassComponent(componentType, _extends({}, child.props)), props);
618+
}
619+
588620
return null;
589621
}
590622
});

dist/react-static-google-map.esm.js

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,22 @@ function locationBuilder(location) {
277277
return urlParts.join('%7C'); // |
278278
}
279279

280+
function isStatelessComponent(component) {
281+
return !component.render && !(component.prototype && component.prototype.render);
282+
}
283+
284+
function isClassComponent(component) {
285+
return Boolean(component && component.prototype.isReactComponent && component.prototype.render);
286+
}
287+
288+
function renderStatelessComponent(component, props) {
289+
return component(props);
290+
}
291+
292+
function renderClassComponent(component, props) {
293+
return new component(props).render();
294+
}
295+
280296
var markerStrategy = function markerStrategy(_ref, parentProps) {
281297
var props = _ref.props;
282298
var size = props.size,
@@ -565,19 +581,35 @@ var StaticGoogleMap = function (_Component) {
565581
createClass(StaticGoogleMap, [{
566582
key: 'buildParts',
567583
value: function buildParts(children, props) {
568-
return React.Children.map(children, function (Child) {
569-
switch (Child.type.name) {
584+
var _this2 = this;
585+
586+
return React.Children.map(children, function (child) {
587+
if (!React.isValidElement(child)) {
588+
return null;
589+
}
590+
591+
switch (child.type.name) {
570592
case 'Marker':
571-
return markerStrategy(Child, props);
593+
return markerStrategy(child, props);
572594
case 'MarkerGroup':
573-
return markerGroupStrategy(Child, props);
595+
return markerGroupStrategy(child, props);
574596
case 'Path':
575-
return pathStrategy(Child, props);
597+
return pathStrategy(child, props);
576598
case 'PathGroup':
577-
return pathGroupStrategy(Child, props);
599+
return pathGroupStrategy(child, props);
578600
case 'Direction':
579-
return directionStrategy(Child, props);
601+
return directionStrategy(child, props);
580602
default:
603+
var componentType = child.type;
604+
605+
if (isStatelessComponent(componentType)) {
606+
return _this2.buildParts(renderStatelessComponent(componentType, _extends({}, child.props)), props);
607+
}
608+
609+
if (isClassComponent(componentType)) {
610+
return _this2.buildParts(renderClassComponent(componentType, _extends({}, child.props)), props);
611+
}
612+
581613
return null;
582614
}
583615
});

dist/react-static-google-map.umd.js

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,22 @@ function locationBuilder(location) {
446446
return urlParts.join('%7C'); // |
447447
}
448448

449+
function isStatelessComponent(component) {
450+
return !component.render && !(component.prototype && component.prototype.render);
451+
}
452+
453+
function isClassComponent(component) {
454+
return Boolean(component && component.prototype.isReactComponent && component.prototype.render);
455+
}
456+
457+
function renderStatelessComponent(component, props) {
458+
return component(props);
459+
}
460+
461+
function renderClassComponent(component, props) {
462+
return new component(props).render();
463+
}
464+
449465
var markerStrategy = function markerStrategy(_ref, parentProps) {
450466
var props = _ref.props;
451467
var size = props.size,
@@ -734,19 +750,35 @@ var StaticGoogleMap = function (_Component) {
734750
createClass(StaticGoogleMap, [{
735751
key: 'buildParts',
736752
value: function buildParts(children, props) {
737-
return React__default.Children.map(children, function (Child) {
738-
switch (Child.type.name) {
753+
var _this2 = this;
754+
755+
return React__default.Children.map(children, function (child) {
756+
if (!React__default.isValidElement(child)) {
757+
return null;
758+
}
759+
760+
switch (child.type.name) {
739761
case 'Marker':
740-
return markerStrategy(Child, props);
762+
return markerStrategy(child, props);
741763
case 'MarkerGroup':
742-
return markerGroupStrategy(Child, props);
764+
return markerGroupStrategy(child, props);
743765
case 'Path':
744-
return pathStrategy(Child, props);
766+
return pathStrategy(child, props);
745767
case 'PathGroup':
746-
return pathGroupStrategy(Child, props);
768+
return pathGroupStrategy(child, props);
747769
case 'Direction':
748-
return directionStrategy(Child, props);
770+
return directionStrategy(child, props);
749771
default:
772+
var componentType = child.type;
773+
774+
if (isStatelessComponent(componentType)) {
775+
return _this2.buildParts(renderStatelessComponent(componentType, _extends({}, child.props)), props);
776+
}
777+
778+
if (isClassComponent(componentType)) {
779+
return _this2.buildParts(renderClassComponent(componentType, _extends({}, child.props)), props);
780+
}
781+
750782
return null;
751783
}
752784
});

0 commit comments

Comments
 (0)