Skip to content

Commit

Permalink
Merge pull request emberjs#1 from gauthierm/cleanup-ie8-immutable-typ…
Browse files Browse the repository at this point in the history
…e-fix

Only compute mutable type flag once and clean up var initilization.
  • Loading branch information
xcskier56 committed Oct 27, 2015
2 parents dd57452 + 7921711 commit d6510a8
Showing 1 changed file with 17 additions and 16 deletions.
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

0 comments on commit d6510a8

Please sign in to comment.