Skip to content

Commit

Permalink
Rad 2626 override set keywords (prebid#3448)
Browse files Browse the repository at this point in the history
* 3413-Insert Iframes for user sync in body

* Append Iframe as the last child

* Add unit test for insertElement

* utls insert element at the top by default

* add unit tests for utls insert element

* Insert iframe as html last child

* revert package.lock changes

* Override keywords in setTargetingForAst
  • Loading branch information
deekshithraop authored and Pedro López Jiménez committed Mar 18, 2019
1 parent e8d18b9 commit 4ca83c5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/targeting.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export function newTargeting(auctionManager) {
// pt${n} keys should not be uppercased
keywordsObj[key] = astTargeting[targetId][key];
}
window.apntag.setKeywords(targetId, keywordsObj);
window.apntag.setKeywords(targetId, keywordsObj, { overrideKeyValue: true });
}
})
);
Expand Down
22 changes: 17 additions & 5 deletions test/spec/unit/pbjs_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,30 @@ var createTagAST = function() {
window.apntag = {
keywords: [],
tags: createTagAST(),
setKeywords: function(key, params) {
setKeywords: function(key, params, options) {
var self = this;
if (!self.tags.hasOwnProperty(key)) {
return;
}
self.tags[key].keywords = this.tags[key].keywords || {};

utils._each(params, function(param, id) {
if (!self.tags[key].keywords.hasOwnProperty(id)) { self.tags[key].keywords[id] = param; } else if (!utils.isArray(self.tags[key].keywords[id])) { self.tags[key].keywords[id] = [self.tags[key].keywords[id]].concat(param); } else { self.tags[key].keywords[id] = self.tags[key].keywords[id].concat(param); }
});
if (typeof options === 'object' && options !== null && options.overrideKeyValue === true) {
utils._each(params, function(param, id) {
self.tags[key].keywords[id] = param;
});
} else {
utils._each(params, function (param, id) {
if (!self.tags[key].keywords.hasOwnProperty(id)) {
self.tags[key].keywords[id] = param;
} else if (!utils.isArray(self.tags[key].keywords[id])) {
self.tags[key].keywords[id] = [self.tags[key].keywords[id]].concat(param);
} else {
self.tags[key].keywords[id] = self.tags[key].keywords[id].concat(param);
}
})
}
}
};
}

describe('Unit: Prebid Module', function () {
let bidExpiryStub;
Expand Down

0 comments on commit 4ca83c5

Please sign in to comment.