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

Simple: Patch node.style.animation to work when undefined #587

Closed
uglow opened this issue May 16, 2017 · 1 comment · Fixed by #598
Closed

Simple: Patch node.style.animation to work when undefined #587

uglow opened this issue May 16, 2017 · 1 comment · Fixed by #598
Labels

Comments

@uglow
Copy link

uglow commented May 16, 2017

In https://github.com/sveltejs/svelte/blob/master/src/shared/transitions.js:

export function generateKeyframes ( a, b, delta, duration, ease, fn, node, style ) {
	var id = '__svelte' + ~~( Math.random() * 1e9 ); // TODO make this more robust
	var keyframes = '@keyframes ' + id + '{\n';

	for ( var p = 0; p <= 1; p += 16.666 / duration ) {
		var t = a + delta * ease( p );
		keyframes += ( p * 100 ) + '%{' + fn( t ) + '}\n';
	}

	keyframes += '100% {' + fn( b ) + '}\n}';
	style.textContent += keyframes;

	document.head.appendChild( style );

	node.style.animation = node.style.animation.split( ',' )    // <----- Change this line
		.filter( function ( anim ) {
			// when introing, discard old animations if there are any
			return anim && ( delta < 0 || !/__svelte/.test( anim ) );
		})
		.concat( id + ' ' + duration + 'ms linear 1 forwards' )
		.join( ', ' );
}

In PhantomJS (which is nearing end-of-life, but some of us still need to use it), the node.style.animation = ... line produces an error (see sveltejs/svelte-transitions#2).

When this line is changed to:

	node.style.animation = (node.style.animation || '').split( ',' )

... PhantomJS runs as expected.

I know this is a PhantomJS bug, but PhantomJS is no longer maintained.

@uglow uglow changed the title Simple: Allow node.style.animation to be undefined Simple: Patch node.style.animation to be work when undefined May 16, 2017
@uglow uglow changed the title Simple: Patch node.style.animation to be work when undefined Simple: Patch node.style.animation to work when undefined May 16, 2017
@PaulBGD
Copy link
Member

PaulBGD commented May 16, 2017

Well, actually any unknown CSS property returns undefined and according to this http://caniuse.com/#feat=css-animation IE<10 doesn't support CSS animations. So this would also be a fix for those browsers.

Rich-Harris added a commit that referenced this issue May 27, 2017
fix for environments where node.style.animation is undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants