fix(animations): always render end-state styles for orphaned DOM nodes (#24236)

This patch ensures that any destination animation styling (state values)
are always applied even if the DOM node is not apart of the DOM.

PR Close #24236
This commit is contained in:
Matias Niemelä
2018-05-31 14:51:30 -07:00
committed by Miško Hevery
parent f3c9954a68
commit 0139173c7c
3 changed files with 40 additions and 15 deletions

View File

@ -623,6 +623,23 @@ const DEFAULT_NAMESPACE_ID = 'id';
const TRIGGER = 'fooTrigger';
expect(() => { engine.trigger(ID, element, TRIGGER, 'something'); }).not.toThrow();
});
it('should still apply state-styling to an element even if it is not yet inserted into the DOM',
() => {
const engine = makeEngine();
const orphanElement = document.createElement('div');
orphanElement.classList.add('orphan');
registerTrigger(
orphanElement, engine, trigger('trig', [
state('go', style({opacity: 0.5})), transition('* => go', animate(1000))
]));
setProperty(orphanElement, engine, 'trig', 'go');
engine.flush();
expect(engine.players.length).toEqual(0);
expect(orphanElement.style.opacity).toEqual('0.5');
});
});
});
})();