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

Only compute mutable type flag once and clean up var initilization. #1

Merged
Merged
Changes from all commits
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
33 changes: 17 additions & 16 deletions packages/ember-views/lib/system/build-component-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,29 @@ export default function buildComponentTemplate({ component, layout, isAngleBrack
return { createdElement: !!tagName, block: blockToRender };
}

function canChangeTypeAfterRender(attrs) {
// This permits testing of the unbound type attr behavior outside of IE8.
if (attrs.ie8SafeInput) {
return false;
}
var mutableInputTypeTextElement, docFragment;
if (!docFragment) {
docFragment = document.createDocumentFragment();
}

if (!mutableInputTypeTextElement) {
mutableInputTypeTextElement = document.createElement('input');
mutableInputTypeTextElement.type = 'text';
}

// Static flag used to see if we can mutate the type attribute on elements. IE8
// does not support changing the type attribute after an element is inserted in
// a tree.
var isTypeAttributeMutable = (function() {
var docFragment = document.createDocumentFragment();
var mutableInputTypeTextElement = document.createElement('input');
mutableInputTypeTextElement.type = 'text';
try {
docFragment.appendChild(mutableInputTypeTextElement);
mutableInputTypeTextElement.setAttribute('type', 'password');
} catch(e) {
} catch (e) {
return false;
}
return true;
})();

function canChangeTypeAfterRender(attrs) {
// This permits testing of the unbound type attr behavior outside of IE8.
if (attrs.ie8SafeInput) {
return false;
}

return isTypeAttributeMutable;
}

function blockFor(template, options) {
Expand Down