Skip to content

Commit

Permalink
respond to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
TakenPilot committed Aug 20, 2015
1 parent b12a3d4 commit 20e4962
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 30 deletions.
8 changes: 4 additions & 4 deletions publishing-rules/ban-tk.js
Expand Up @@ -3,7 +3,7 @@ var label, description,
articleFields = ['primaryHeadline', 'teaser'],
paragraphField = 'text',
_ = require('lodash'),
dom = require('../services/dom'),
stripTags = require('striptags'),
references = require('../services/references'),
refProp = references.referenceProperty,
cutStart = 20,
Expand Down Expand Up @@ -84,7 +84,7 @@ function addError(component, fieldName, errors, tkText) {
data = component && component[fieldName],
schema = data._schema,
label = schema && schema._label,
value = data && data.value && dom.removeTags(data.value),
value = data && data.value && stripTags(data.value),
error = {
ref: ref,
fieldName: fieldName,
Expand All @@ -107,7 +107,7 @@ function validate(state) {

_.each(groups.paragraph, function (component) {
var field = component[paragraphField],
value = field && field.value && dom.removeTags(field.value),
value = field && field.value && stripTags(field.value),
tkText = value && findFirstText(value, searchTexts);

if (tkText) {
Expand All @@ -120,7 +120,7 @@ function validate(state) {
_.each(groups.article, function (component) {
_.each(articleFields, function (fieldName) {
var field = component[fieldName],
value = field && field.value && dom.removeTags(field.value),
value = field && field.value && stripTags(field.value),
tkText = value && findFirstText(value, searchTexts);

if (tkText) {
Expand Down
18 changes: 0 additions & 18 deletions services/dom.js
Expand Up @@ -211,23 +211,5 @@ module.exports = {
observer.observe(el.parentNode, {childList: true});
},

/**
* Remove HTML tags from string
* @param {string} str
* @returns {string}
*/
removeTags: function (str) {
var start = str.indexOf('<'),
end = start > -1 && str.indexOf('>', start) || start;

while (start > -1 && end > -1) {
str = str.substring(0, start) + str.substring(end + 1);
start = str.indexOf('<');
end = start > -1 && str.indexOf('>') || start;
}

return str;
},

create: domify // create elements from strings!
};
8 changes: 0 additions & 8 deletions services/dom.test.js
Expand Up @@ -189,12 +189,4 @@ describe('dom service', function () {
expect(mockMutationObserver.disconnect.callCount).to.equal(1);
});
});

describe('removeTags', function () {
var fn = dom[this.title];

it('removes tags', function () {
expect(fn('a<>c<d>e<f>g</h>')).to.equal('aceg');
});
});
});

0 comments on commit 20e4962

Please sign in to comment.