Issue #5775πŸ’¬ AnsweredOpened Mar 26, 2024by ctrhub0 reactions

Component.get('traits').clone() is no longer available.

Quick answerby artf

If you need to make a copy of traits I'd suggest simply doing this JSON.parse(JSON.stringify(editor.getSelected().getTraits())). I don't remember ever mentioning cloning traits in docs, so I'd avoid using non-public APIs.

Read full answer below ↓

Question

GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Arc Version 1.35.0 / Chromium Engine 123.0 Reproducible demo link https://grapesjs.com/demo.html Describe the bug How to reproduce the bug?Open dev toolsSelect a componentRun in console: What is the expected behavior? Should return cloned version. What is the current behavior? Throws an error: If is necessary to execute some code in order to reproduce the bug, paste it here below: --- Note: .clone() is the only method I found that no longer works. Link to the method - https://arc.net/l/quote/ztapw...

Answers (2)

artfβ€’ Apr 1, 2024

If you need to make a copy of traits I'd suggest simply doing this JSON.parse(JSON.stringify(editor.getSelected().getTraits())). I don't remember ever mentioning cloning traits in docs, so I'd avoid using non-public APIs.

GJS Helperβ€’ May 17, 2026

You've identified a legitimate bug in GrapesJS where calling component.get('traits').clone() throws a TypeError. This issue arises because the Traits collection's clone() method, which internally relies on Backbone.Collection.prototype.clone(), attempts to instantiate a new Traits collection using...

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins β†’
Premium option

Premium plugins ship with support, regular updates, and production-ready features β€” save days of integration work.

Browse premium plugins β†’

Related tutorials

In-depth guides on the same topic.

All tutorials β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.