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

Fix/iframe attributes #269

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/featherlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,31 @@
'sandbox', 'src', 'srcdoc', 'width'],
attrs = {};

whiteList.map(function(item) {
$.each(whiteList, function(index, item) {
var attrValue = parseAttrs(obj, 'iframe')[item];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed, but would be better to call parseAttrs once instead of once per item in whiteList...


if (attrValue) {
attrs[item] = attrValue;
return attrs[item];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless return.

}
}
});

return attrs;
}
};

function parseAttrs(obj, prefix) {
var attrs = {},
regex = new RegExp('^' + prefix + '([A-Z])(.*)');
for (var key in obj) {
var match = key.match(regex);
if (match) {
var dasherized = (match[1] + match[2].replace(/([A-Z])/g, '-$1')).toLowerCase();
attrs[dasherized] = obj[key];
function parseAttrs(obj, prefix) {
var attrs = {},
regex = new RegExp('^' + prefix + '([A-Z])(.*)');
for (var key in obj) {
var match = key.match(regex);
if (match) {
var dasherized = (match[1] + match[2].replace(/([A-Z])/g, '-$1')).toLowerCase();
attrs[dasherized] = obj[key];
}
}
return attrs;
}
return attrs;
}

/* document wide key handler */
var eventMap = { keyup: 'onKeyUp', resize: 'onResize' };
Expand Down