UXP vs. Tycho: breaking changes

Discussions about the development and maturation of the Unified XUL Platform (UXP).
Warning: may contain highly-technical topics.

Moderators: trava90, satrow

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 21462
Joined: Sun, 28 Aug 2011, 17:27
Location: 58.5°N 15.5°E
Contact:

UXP vs. Tycho: breaking changes

Unread postby Moonchild » Thu, 05 Jul 2018, 17:04

This post is meant to be a summary overview of breaking changes in our browser implementation that will affect extensions.
If your Pale Moon 27 compatible extension is affected, it will almost certainly need to be updated to be compatible with Pale Moon 28 and other UXP applications.

These are the most likely issues you may run into. This is by no means a complete list.

Global scope getters and setters

Symptom: usually an error is thrown in the console:
TypeError: can't convert undefined to object


Previously, the __defineGetter__ and __defineSetter__ methods could be called at the global scope without any object, because the global object was automatically used in such cases. As part of ECMAScript 2016 compliance, Pale Moon 28 and later no longer support the legacy behavior and throw a TypeError instead. The workaround here is to explicitly use the this keyword, like this.__defineGetter__ or this.__defineSetter__.

Global scope 'let'

Since we've moved to a single global scope for the browser, any top-level scope objects can no longer be declared with the let or const keywords, or they may not be available to function callers. Declare global scope objects with var instead.

Python-like array assignments

Symptom: usually an error is thrown in the console:
SyntaxError: Missing ] after element list


Previously, Pale Moon would accept array assignments in the form:

Code: Select all

var tagetArray = [element for each (item in list)];

This non-standard assignment method is no longer supported and has to be rewritten, depending on the loop and operation with Array.from(), Array.push(), or map statements.

prototype.__NoSuchMethod__

The non-standard Object.prototype.__noSuchMethod__ property has been removed. The standard Proxy object defined in the ECMAScript 6 specification can be used instead.

Destructuring for..in loops have been removed

The non-standard implementation of destructuring for...in loops (a JavaScript 1.7-only extension), like for (var/let/const [key, value] in object), has been removed. For an Array or other iterable objects, you can simply use the for...of loop instead.
For a general Object, a proper solution might be for (let key in obj) { let value = obj[key]; }.

Parenthesized destructuring patterns

As part of the ES6 specification compliance, parenthesized destructuring patterns, like ([a, b]) = [1, 2] or ({a, b}) = { a: 1, b: 2 }, are now considered invalid and will throw a SyntaxError.

Method definitions require { }

Previously, curly brackets { } were not required in method definitions. Starting with Pale Moon 28 and other UXP applications, those are required as per the ECMAScript 6 specification and will throw a SyntaxError if missing.

Map/Set/WeakMap constructors require 'new'

As part of the ES6 specification compliance, we now throw a TypeError if you call one of the Map, Set or WeakMap constructors without using the new operator.
Improving Mozilla code: You know you're on the right track with code changes when you spend the majority of your time deleting code.

"If you want to build a better world for yourself, you have to be willing to build one for everybody." -- Coyote Osborne

Return to “UXP development”

Who is online

Users browsing this forum: No registered users and 2 guests