Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rad 2626 override set keywords #3448

Merged
merged 11 commits into from
Jan 15, 2019
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