Skip to content

Overwritten method Object.defineProperty breaking functionality of jsPDF #31659

@sirhcybe

Description

@sirhcybe

The rewriteDescriptor function being called by the zone.js Object.defineProperty override is breaking some functionality of the popular jsPDF library: parallax/jsPDF#2429

I don't really understand why the rewriteDescriptor method changes the desc.configurable to true but it breaks several places in the jsPDF code where jsPDF tries to define non-configurable properties like this:

var _BBox = [];
Object.defineProperty(this, 'BBox', {
   configurable: false,
   writeable: true,
   get: function () {
       return _BBox;
   },
   set: function (value) {
       _BBox = value;
   }
});

It could be fixed by freezing the desc object in jsPDF like this:

var _BBox = [];
Object.defineProperty(this, 'BBox', Object.freeze({
   configurable: false,
   writeable: true,
   get: function () {
       return _BBox;
   },
   set: function (value) {
       _BBox = value;
   }
}));

However, the jsPDF maintainers make a good point when they ask why they should change their code when it's adhering to standard functionality. I really can't answer that as I don't know enough about zone.js but I hope someone here can help us get this figured out.

Metadata

Metadata

Assignees

Labels

area: zonesIssues related to zone.js

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions