Skip to content

Commit

Permalink
Added idName prop
Browse files Browse the repository at this point in the history
  • Loading branch information
brunomarchioro committed Dec 3, 2019
1 parent 81532b4 commit 1bb1c6b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-gpt",
"version": "2.0.12",
"version": "2.0.13",
"description": "A react display ad component using Google Publisher Tag",
"main": "lib/index.js",
"jsnext:main": "es/index.js",
Expand Down
10 changes: 8 additions & 2 deletions src/Bling.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class Bling extends Component {
* @property id
*/
id: PropTypes.string,
/**
* An optional string to be used as prefix to element id.
*
* @property idName
*/
idName: PropTypes.string,
/**
* An optional string to be used as container div class.
*
Expand Down Expand Up @@ -748,7 +754,7 @@ class Bling extends Component {

render() {
const {scriptLoaded} = this.state;
const {id, className, outOfPage, style} = this.props;
const {id, idName, className, outOfPage, style} = this.props;
const shouldNotRender = this.notInViewport(this.props, this.state);

if (!scriptLoaded || shouldNotRender) {
Expand Down Expand Up @@ -785,7 +791,7 @@ class Bling extends Component {
Bling._adManager.googletag.destroySlots([this._adSlot]);
this._adSlot = null;
}
this._divId = id || Bling._adManager.generateDivId();
this._divId = id || Bling._adManager.generateDivId(idName);

return <div className={className} id={this._divId} style={style} />;
}
Expand Down
4 changes: 2 additions & 2 deletions src/createManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ export class AdManager extends EventEmitter {
this._syncCorrelator = value;
}

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

getMountedInstances() {
Expand Down

0 comments on commit 1bb1c6b

Please sign in to comment.