Path: blob/main/files/en-us/mozilla/add-ons/webextensions/api/bookmarks/removetree/index.md
6552 views
------{{AddonSidebar()}}
The bookmarks.removeTree() method recursively removes a bookmark folder and all of its contents.
Warning: If your extension attempts to remove a bookmark tree from the bookmarks tree root node, the call will raise an error with the message: "The bookmark root cannot be modified" and the bookmark won't be removed.
This is an asynchronous function that returns a Promise.
Syntax
Parameters
id: A {{jsxref("string")}} specifying the ID of the folder node to be deleted along with its descendants.
Return value
A Promise that will be fulfilled with no arguments when the tree has been removed.
If the node corresponding to the id parameter can't be found, the promise is rejected with an error message.
Examples
This example locates a bookmark folder named "MDN" and deletes it along with all of its contents.
{{WebExtExamples}}
Browser compatibility
{{Compat}}
Note: This API is based on Chromium's
chrome.bookmarksAPI. This documentation is derived frombookmarks.jsonin the Chromium code.