Skip to content

Commit 1bb1c6b

Browse files
Added idName prop
1 parent 81532b4 commit 1bb1c6b

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-gpt",
3-
"version": "2.0.12",
3+
"version": "2.0.13",
44
"description": "A react display ad component using Google Publisher Tag",
55
"main": "lib/index.js",
66
"jsnext:main": "es/index.js",

src/Bling.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ class Bling extends Component {
2929
* @property id
3030
*/
3131
id: PropTypes.string,
32+
/**
33+
* An optional string to be used as prefix to element id.
34+
*
35+
* @property idName
36+
*/
37+
idName: PropTypes.string,
3238
/**
3339
* An optional string to be used as container div class.
3440
*
@@ -748,7 +754,7 @@ class Bling extends Component {
748754

749755
render() {
750756
const {scriptLoaded} = this.state;
751-
const {id, className, outOfPage, style} = this.props;
757+
const {id, idName, className, outOfPage, style} = this.props;
752758
const shouldNotRender = this.notInViewport(this.props, this.state);
753759

754760
if (!scriptLoaded || shouldNotRender) {
@@ -785,7 +791,7 @@ class Bling extends Component {
785791
Bling._adManager.googletag.destroySlots([this._adSlot]);
786792
this._adSlot = null;
787793
}
788-
this._divId = id || Bling._adManager.generateDivId();
794+
this._divId = id || Bling._adManager.generateDivId(idName);
789795

790796
return <div className={className} id={this._divId} style={style} />;
791797
}

src/createManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ export class AdManager extends EventEmitter {
222222
this._syncCorrelator = value;
223223
}
224224

225-
generateDivId() {
226-
return `bling-${++this._adCnt}`;
225+
generateDivId(idName = "bling") {
226+
return `${idName}-${++this._adCnt}`;
227227
}
228228

229229
getMountedInstances() {

0 commit comments

Comments
 (0)