mirror of
https://github.com/google/material-design-lite.git
synced 2024-09-11 12:25:38 +03:00
Merge pull request #4110 from google/deconstruct-buletproofing
Add some bulletproofing to deconstructComponentInternal.
This commit is contained in:
commit
48cdbd9340
@ -342,17 +342,19 @@ componentHandler = (function() {
|
||||
* @param {?componentHandler.Component} component
|
||||
*/
|
||||
function deconstructComponentInternal(component) {
|
||||
var componentIndex = createdComponents_.indexOf(component);
|
||||
createdComponents_.splice(componentIndex, 1);
|
||||
if (component) {
|
||||
var componentIndex = createdComponents_.indexOf(component);
|
||||
createdComponents_.splice(componentIndex, 1);
|
||||
|
||||
var upgrades = component.element_.getAttribute('data-upgraded').split(',');
|
||||
var componentPlace = upgrades.indexOf(component[componentConfigProperty_].classAsString);
|
||||
upgrades.splice(componentPlace, 1);
|
||||
component.element_.setAttribute('data-upgraded', upgrades.join(','));
|
||||
var upgrades = component.element_.getAttribute('data-upgraded').split(',');
|
||||
var componentPlace = upgrades.indexOf(component[componentConfigProperty_].classAsString);
|
||||
upgrades.splice(componentPlace, 1);
|
||||
component.element_.setAttribute('data-upgraded', upgrades.join(','));
|
||||
|
||||
var ev = document.createEvent('Events');
|
||||
ev.initEvent('mdl-componentdowngraded', true, true);
|
||||
component.element_.dispatchEvent(ev);
|
||||
var ev = document.createEvent('Events');
|
||||
ev.initEvent('mdl-componentdowngraded', true, true);
|
||||
component.element_.dispatchEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user