cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

checking element equality in javascript (rhino)

jsulak
1-Visitor

checking element equality in javascript (rhino)

Hey everybody,

Let's say I do the following in Arbortext:

var document = Application.activeDocument;
var a = document.getElementById("stuff");
var b = document.getElementById("stuff");

So both a and b point to the same DOM element. Now, if I check their equality:

a == b

I get "false." Why is that? Shouldn't both variables contain references to the same object, and therefore be equal? Is there a simple way to check for element equality in javascript?

Note that when I do the same thing in a web browser, I get "true," like I expect.

Thanks,

James


2 REPLIES 2

Hi James--

Try a.equals(b).

(FWIW, I think the behavior you're seeing is due to the way everything
in Rhino is actually Java objects under the hood.)

--Clay
jsulak
1-Visitor
(To:jsulak)

Thanks, Clay, that works perfectly.

-James
Announcements

Top Tags