| 1 |
import isModifierEnabled from '../utils/isModifierEnabled'; |
| 2 |
import getSupportedPropertyName from '../utils/getSupportedPropertyName'; |
| 3 |
|
| 4 |
/** |
| 5 |
* Destroys the popper. |
| 6 |
* @method |
| 7 |
* @memberof Popper |
| 8 |
*/ |
| 9 |
export default function destroy() { |
| 10 |
this.state.isDestroyed = true; |
| 11 |
|
| 12 |
// touch DOM only if `applyStyle` modifier is enabled |
| 13 |
if (isModifierEnabled(this.modifiers, 'applyStyle')) { |
| 14 |
this.popper.removeAttribute('x-placement'); |
| 15 |
this.popper.style.position = ''; |
| 16 |
this.popper.style.top = ''; |
| 17 |
this.popper.style.left = ''; |
| 18 |
this.popper.style.right = ''; |
| 19 |
this.popper.style.bottom = ''; |
| 20 |
this.popper.style.willChange = ''; |
| 21 |
this.popper.style[getSupportedPropertyName('transform')] = ''; |
| 22 |
} |
| 23 |
|
| 24 |
this.disableEventListeners(); |
| 25 |
|
| 26 |
// remove the popper if user explicitly asked for the deletion on destroy |
| 27 |
// do not use `remove` because IE11 doesn't support it |
| 28 |
if (this.options.removeOnDestroy) { |
| 29 |
this.popper.parentNode.removeChild(this.popper); |
| 30 |
} |
| 31 |
return this; |
| 32 |
} |