Project

Profile

Help

Bug #3545

closed

Inconsistencies using map functions on JS objects

Added by Debbie Lockett over 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Category:
-
Sprint/Milestone:
-
Start date:
2017-11-23
Due date:
% Done:

100%

Estimated time:
Applies to JS Branch:
1.0, Trunk
Fix Committed on JS Branch:
1.0, Trunk
Fixed in JS Release:
SEF Generated with:
Platforms:
Company:
-
Contact person:
-
Additional contact persons:
-

Description

Within XPath, JavaScript objects are treated as XDM maps, allowing properties to be accessed using the XPath map functions. However it seems there are a number of problems with the way this is implemented.

Firstly, map:contains($obj, 'prop') returns true when 'prop' is NOT a property on the JS Object obj. It appears we are currently testing obj[prop] !== null, but this is wrong since obj[prop] is undefined (not null) if prop is not a property of obj!

Secondly, we are inconsistent about whether we include only direct properties of an object, or also the inherited properties (from the object's prototype chain; e.g. 'toString' is a property on all JS Objects):

  • currently map:get($obj, 'prop') returns any property on the JS object obj, direct or inherited, since internally we use obj[prop]

  • while map:keys($obj) returns only the direct properties of obj, since internally we use obj.hasOwnProperty

Please register to edit this issue

Also available in: Atom PDF Tracking page