You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A witness is an array of DesignatedObject that explains the violation of a condition. Each DesignatedObject contains a Designator, which points to a part of an object, and an Object it refers to.
In the context of DOM nodes, the designated object can have two forms.
First form
The designator is a CompoundDesignator, which is a composition of elementary ("atomic") designators. The composition ends with a Path, followed by a ConstantDesignator. The object is an HTMLBodyElement. This means that this piece of the witness points to an element of the DOM tree, indicated by the XPath expression contained in the Path instance.
For example, the following picture shows the structure of such a designated object (dob1) in one of the unit tests.
Second form
The second form is any designated object that does not correspond to the previous structure (it should normally end with a ConstantDesignator). Typically, it will point to objects that are user-provided constants, such as numbers or strings, that cannot be linked to the DOM tree.
To do
As a first step before transforming an arbitrary and-or tree into a DataTree (see #2), we will convert a witness into a DataTree. The process is as follows:
Each element of the witness becomes a leaf of the data tree.
If the designated object is of the first form, the subject attribute contains the XPath of the Path designator. The part attribute contains an array with the string representation of all the designators that come before the path.
If the designated object is of the second form, the subject attribute contains the object pointed by the DesignatedObject (obtained through the getObject()) method. The part attribute contains an array with the string representation of all the designators (except the last ConstantDesignator).
These leaves are topped by an "and" node, as per the structure described in the Google Drive document.
This should be implemented in index.mjs through a function called getTreeFromWitness(w), which takes a witness and returns the corresponding DataTree. Unit tests should be added to a new file called test/index.test.js.
The text was updated successfully, but these errors were encountered:
A witness is an array of
DesignatedObject
that explains the violation of a condition. EachDesignatedObject
contains aDesignator
, which points to a part of an object, and anObject
it refers to.In the context of DOM nodes, the designated object can have two forms.
First form
The designator is a
CompoundDesignator
, which is a composition of elementary ("atomic") designators. The composition ends with aPath
, followed by aConstantDesignator
. The object is anHTMLBodyElement
. This means that this piece of the witness points to an element of the DOM tree, indicated by the XPath expression contained in thePath
instance.For example, the following picture shows the structure of such a designated object (
dob1
) in one of the unit tests.Second form
The second form is any designated object that does not correspond to the previous structure (it should normally end with a
ConstantDesignator
). Typically, it will point to objects that are user-provided constants, such as numbers or strings, that cannot be linked to the DOM tree.To do
As a first step before transforming an arbitrary and-or tree into a DataTree (see #2), we will convert a witness into a DataTree. The process is as follows:
subject
attribute contains the XPath of thePath
designator. Thepart
attribute contains an array with the string representation of all the designators that come before the path.subject
attribute contains the object pointed by theDesignatedObject
(obtained through thegetObject()
) method. Thepart
attribute contains an array with the string representation of all the designators (except the lastConstantDesignator
).This should be implemented in
index.mjs
through a function calledgetTreeFromWitness(w)
, which takes a witness and returns the corresponding DataTree. Unit tests should be added to a new file calledtest/index.test.js
.The text was updated successfully, but these errors were encountered: