Overview
Backport allows you to remove deprecated JS API features.This should only be used if the newer (replacement) feature has already been backported.
By removing deprecated features you can more easily check that your script isn't relying on them sooner rather than later.
Accessing removed features will cause exceptions (errors) so you can quickly spot if your script is using them (the filename and line number will usually be shown).
The feature is not actually removed (it's not possible to do so) - instead, it's replaced with a value of undefined
.
Availability
Backport v0.1 and above.
Syntax
// remove a deprecated feature var returnValue = backport(name,null);
Parameters
Parameter | Type | Mandatory | Description | Backport version |
---|---|---|---|---|
name | String | The name of the feature as a string (in quotes). | 0.1 | |
null | Null | Specifying a value of null or undefined causes feature with 'name' to be removed. | 0.1 |
Return value
Value | Type | Description | Backport verison |
---|---|---|---|
<status> | Variant | The new status of the constant (see status return values). | 0.1 |
Example
// droidFromId() was deprecated in Warzone 3.1 Beta 2, it was replaced with objFromId() // we need to make sure the new function, objFromId() exists before deleting droidFromId() if (!backport("objFromId") && backport("droidFromId")) { // we're on 3.1 Beta 1 // objFromId() is exactly the same as droidFromId() so we can backport it easily backport("objFromId",droidFromId); // returns -1 === feature added by backport } // now we know objFromId() exists, we can delete droidFromId() backport("droidFromId",null); // returns null === feature removed by backport
See also
- Adding missing constants – how to add missing API constants
- Check status of an API feature – how to check the status of an API feature
- Listing API features – get a list of all API features that are present or removed