• Resolved David Bennett

    (@bennettskaya)


    I ran a Google ‘mobile friendly’ test and it said there was an ‘Uncaught SyntaxError: Unexpected token =>’

    The details gave me a source “mysite dot com/wp-content/plugins/atomic-blocks/dist/assets/js/dismiss.js?ver=1556813107:6”

    I put that into a browser, it gives this:

    (function($) {
    
    	$(document).ready(function() {
    
    		const elems = document.querySelectorAll('.ab-block-notice.ab-dismissable[data-id]');
    		elems.forEach(el => {
    			const uid = el.getAttribute( 'data-id' );
    			if ( ! localStorage.getItem(<code>notice-${uid}</code>) ) {
    				el.style.display = 'block';
    			}
    
    			if ( $( '.ab-notice-dismiss' ).length ) {
    				el.querySelector('.ab-notice-dismiss').addEventListener('click', () => {
    					localStorage.setItem(<code>notice-${uid}</code>, 1);
    					el.style.display = '';
    				})
    			}
    		})
    
    	});
    
    })(jQuery);

    Is it problem with the plugin?
    How significant is it?

    Thanks

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author John Parris

    (@mindctrl)

    @bennettskaya it shouldn’t be a problem. Google’s tool is probably complaining about the modern syntax used in that file, which isn’t supported by a few older browsers. I’ll make a note of this and see about converting it to a more compatible syntax.

    Thread Starter David Bennett

    (@bennettskaya)

    Thanks

    Hi,

    this forEach loop throws a syntax error on IE 11 (11.765.17134.0). Although it has a relatively low market share and could be considered an “older” browser I (professionally – not personally ?? consider IE 11 support mandatory.

    To make things worse – if you bundle js files for loading time optimization this may break your entire site. It would be highly appreciated if you could rewrite this loop in the next release. I made local adjustments for now.

    Thanks!

    EDIT: IE 11 doesn’t seem to like template strings or arrow functions either…

    • This reply was modified 5 years, 6 months ago by henron.
    Plugin Author John Parris

    (@mindctrl)

    @henron we’ll have a fix for this in the next update. We’ve rewritten this to be IE compatibility and to remove the jQuery dependency, which will be faster and help with AMP compatibility if you happen to use that.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Uncaught SyntaxError: Unexpected token =>’ is closed to new replies.