missing { before function body in TB 60

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

missing { before function body in TB 60

Graeme
I have an addon that had no errors in TB59 and in TB 60 produces this error.
1522249207376 addons.xpi WARN Error loading bootstrap.js for [hidden email]: SyntaxError: missing { before function body (resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///U:/Settings/Thunderbird/extensions/[hidden email]!/bootstrap.js:39:37)

The line where the error seems to be found is
var self = this,
                addon = {
  getResourceURI: function(filePath) ({
    spec: __SCRIPT_URI_SPEC__ + "/../" + filePath
  })
}

;
But if I comment all this out it finds the same error at another place.
Is there some change in the way it looks at { and } that it would now think there was one missing whereas it didn't one version before?
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: missing { before function body in TB 60

Mark Banner-4
On 28/03/2018 16:20, [hidden email] wrote:

> The line where the error seems to be found is
> var self = this,
> addon = {
>    getResourceURI: function(filePath) ({
>      spec: __SCRIPT_URI_SPEC__ + "/../" + filePath
>    })
> }
>
> ;
> But if I comment all this out it finds the same error at another place.
> Is there some change in the way it looks at { and } that it would now think there was one missing whereas it didn't one version before?
I believe this is a function format that isn't supported any more. You
need to do something like:

getResourceURI: filePath => { spec: ... }

or:

getResourceURI: function(filePath) { return { spec: ... }); }

Mark.
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: missing { before function body in TB 60

Graeme
In reply to this post by Graeme
On Wednesday, March 28, 2018 at 4:38:45 PM UTC+1, Mark Banner wrote:

> On 28/03/2018 16:20, musiquegraeme wrote:
> > The line where the error seems to be found is
> > var self = this,
> > addon = {
> >    getResourceURI: function(filePath) ({
> >      spec: __SCRIPT_URI_SPEC__ + "/../" + filePath
> >    })
> > }
> >
> > ;
> > But if I comment all this out it finds the same error at another place.
> > Is there some change in the way it looks at { and } that it would now think there was one missing whereas it didn't one version before?
> I believe this is a function format that isn't supported any more. You
> need to do something like:
>
> getResourceURI: filePath => { spec: ... }
>
> or:
>
> getResourceURI: function(filePath) { return { spec: ... }); }
>
> Mark.

Are there other function formats that have been depreciated? I have sorted the line above and have the same error at line 300... but the function is much more complicated. Is there a list of formats dropped?
Blessings
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: missing { before function body in TB 60

Mark Banner-4
On 28/03/2018 16:53, [hidden email] wrote:

> On Wednesday, March 28, 2018 at 4:38:45 PM UTC+1, Mark Banner wrote:
>> I believe this is a function format that isn't supported any more. You
>> need to do something like:
>>
>> getResourceURI: filePath => { spec: ... }
>>
>> or:
>>
>> getResourceURI: function(filePath) { return { spec: ... }); }
>>
>> Mark.
> Are there other function formats that have been depreciated? I have sorted the line above and have the same error at line 300... but the function is much more complicated. Is there a list of formats dropped?
As far as I know that's the only one, and when I said format, I should
have said syntax. This is the syntax that has been dropped:
https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Expression_closures

There's https://wiki.mozilla.org/Thunderbird/Add-ons_Guide_57 on what
people know about that has changed.

Mark.
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: missing { before function body in TB 60

Graeme
In reply to this post by Graeme

Thanks for that Mark.
I'm really struggling to see how this applies in my addon.

The line that is producing the same error (Syntax error: missing { before function body) is now
getString.init = function(addon, getAlternate) {

I tried
getString.init = (addon, getAlternate) => {
NO joy... within the expression there is
 let propertyFile = addon.getResourceURI(propertyPath);

and then
 var bundle = Services.strings.createBundle(propertyFile.spec);

All of this is to get a bundle for localisation purposes... Is there a  better way of doing this? I tried searching for localisation in the forum and got no results.

Thanks for your time.
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: missing { before function body in TB 60

Jörg Knobloch
On 29/03/2018 10:51, [hidden email] wrote:
getString.init = function(addon, getAlternate) {

I tried 
getString.init = (addon, getAlternate) => {

Why don't you paste the whole thing or attach it to give us some context.

This works:

let x = {}; x.init = (c,v) => { return (c+v); };

Jörg.



_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: missing { before function body in TB 60

Jörg Knobloch
In reply to this post by Graeme

My reply was blocked, so I'm trying again. Sorry about the variable names, but using a single letter seems to have got the message caught in the SPAM filter.

On 29/03/2018 10:51, [hidden email] wrote:
getString.init = function(addon, getAlternate) {

I tried 
getString.init = (addon, getAlternate) => {

Why don't you paste the whole thing or attach it to give us some context.

This works, try it in the browser console:

let heidi = {}; heidi.init = (klaus, bert) => { return (klaus + bert); };

Jörg.



_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: missing { before function body in TB 60

Stefan Sitter-2
In reply to this post by Graeme
On 28.03.2018 17:53, [hidden email] wrote:
> Are there other function formats that have been depreciated?

You can check Firefox releases for changed or removed JavaScript
features and links to the corresponding documentation and recommended
replacements.

https://developer.mozilla.org/en-US/Firefox/Releases/60#Removals_from_the_web_platform

https://developer.mozilla.org/en-US/Firefox/Releases/59#Removals_from_the_web_platform

https://developer.mozilla.org/en-US/Firefox/Releases/58#Removals_from_the_web_platform

[...]

/Stefan
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird