Trouble understanding Firefox error: SyntaxError: missing } after property list

216 Views Asked by At

I have the following script which provides a local server fallback for fonts:

<!-- load fonts via webfont.js with local fallback: https://github.com/typekit/webfontloader -->
<script src="//ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js"></script>
<script>window.WebFont || document.write('<script src="../assets/js/webfont.js"><\/script>')</script>
<script>
  WebFont.load({

    // load fonts from CDN
    google: {
      families: ['Flamenco']
    },
    custom: {
      families: ['FontAwesome'],
      urls: [ '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css' ]
    }

    // load server fallback if CDN is unavailable
    fontinactive: function (family, fvd) {
      if (family === 'Flamenco' || 'FontAwesome') {
        WebFont.load({
          custom: {
            families: ['Flamenco', 'FontAwesome'],
            urls: [ '../assets/fonts/local-fonts.css' ]
          }
        })
      }
    },
  });
</script>

But firefox states that this line is missing a closing }

fontinactive: function (family, fvd) {

For the life of me I can't work out what's wrong sorry - I'm sure there's a stupid error somewhere.

Any pointers in the right direction would be much appreciated.

Cheers

1

There are 1 best solutions below

0
On

Sorry, had copied the function to the bottom and forgotten about the commas - plus fontinactive needs to go first I think.

Corrected script for my ref:

<!-- load fonts via webfont.js with local fallback: https://github.com/typekit/webfontloader -->
<script src="//ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js"></script>
<script>window.WebFont || document.write('<script src="../assets/js/webfont.js"><\/script>')</script>
<script>
  WebFont.load({

    // load server fallback if CDN is unavailable
    fontinactive: function (family, fvd) {
      if (family === 'Flamenco' || 'FontAwesome') {
        WebFont.load({
          custom: {
            families: ['Flamenco', 'FontAwesome'],
            urls: [ '../assets/fonts/local-fonts.css' ]
          }
        })
      }
    },

    // load fonts from CDN
    google: {
      families: ['Flamenco']
    },
    custom: {
      families: ['FontAwesome'],
      urls: [ '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css' ]
    }
  });
</script>