Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
FabricJS include all attributes in canvas.toObject()

When saving a canvas using canvas.toObject(), custom object attributes are skipped, but also some build in ones such as: borderColor. This can be quite annoying since saving the canvas using canvas.toObject() and loading it again using loadFromJson() can load something that is not the same.

Luckily there is a solution to define properties that should be included in canvas.toObject() which I found in a separate SO thread:

fabric.Object.prototype.toObject = (function (toObject) {
    return function (propertiesToInclude) {
        propertiesToInclude = (propertiesToInclude || []).concat(
          ['uuid','rt_attributes']
        );
        return toObject.apply(this, [propertiesToInclude]);
    };
})(fabric.Object.prototype.toObject);

But however, since in my use case there are a lot of properties to include, I am wondering if there is a way to just include all object attributes when running canvas.toObject(), or in other words, is it possible to disable this filter?

My side question is if anyone knows where I can find this list of attributes that gets ignored when running canvas.toObject()?

Thanks

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!