0

我正在将 Javascript 用于 InDesign 脚本。

我有一个图像对象,想知道它的边界(用户看到的那个) -

bounds = (geometricBounds in image.parent)? image.parent.geometricBounds: image.geometricBounds;

返回ReferenceError - geometricBounds is undefined。当图像的父对象是 Oval 对象时会出现此错误(因此,我知道 geometryBounds 属性适用于 Oval 对象)。

问题出在(geometricBounds in image.parent)因为当我提醒这个声明时,我得到了同样的错误。我肯定遗漏了一些东西——因为如果这不是一个属性,那么我应该得到一个错误的结果。

有谁知道为什么会这样?

4

1 回答 1

2

运算符将in属性名称检查为字符串(在您的情况下,它正在寻找一个名为的变量geometricBounds- 它可能包含属性名称字符串 - 显然没有在任何地方声明):

bounds = ('geometricBounds' in image.parent)? image.parent.geometricBounds: image.geometricBounds;
于 2013-05-24T13:10:48.013 回答