6
6
import java .util .List ;
7
7
import java .util .Map ;
8
8
9
- import org . cyberneko . html .HTMLElements ;
9
+ import net . sourceforge . htmlunit . cyberneko .HTMLElements ;
10
10
import org .jruby .Ruby ;
11
11
import org .jruby .RubyClass ;
12
12
import org .jruby .RubyObject ;
24
24
public class Html4ElementDescription extends RubyObject
25
25
{
26
26
private static final long serialVersionUID = 1L ;
27
+ private static final HTMLElements htmlElements_ = new HTMLElements ();
27
28
28
29
/**
29
30
* Stores memoized hash of element -> list of valid subelements.
@@ -63,9 +64,8 @@ public class Html4ElementDescription extends RubyObject
63
64
* the list of elements directly because it's protected.
64
65
*/
65
66
for (short c = 0 ; c < HTMLElements .UNKNOWN ; c ++) {
66
- HTMLElements .Element maybe_sub =
67
- HTMLElements .getElement (c );
68
- if (maybe_sub .isParent (elem )) {
67
+ HTMLElements .Element maybe_sub = htmlElements_ .getElement (c );
68
+ if (maybe_sub != null && maybe_sub .isParent (elem )) {
69
69
subs .add (maybe_sub .name );
70
70
}
71
71
}
@@ -82,11 +82,10 @@ public class Html4ElementDescription extends RubyObject
82
82
IRubyObject klazz , IRubyObject name )
83
83
{
84
84
85
- // nekohtml will return an element even for invalid names, see
86
- // http://sourceforge.net/p/nekohtml/code/HEAD/tree/trunk/src/org/cyberneko/html/HTMLElements.java#l514
87
- // which breaks `test_fetch_nonexistent'
88
- HTMLElements .Element elem = HTMLElements .getElement (name .asJavaString (), HTMLElements .NO_SUCH_ELEMENT );
89
- if (elem == HTMLElements .NO_SUCH_ELEMENT ) {
85
+ // nekohtml will return an element even for invalid names, which breaks `test_fetch_nonexistent'
86
+ // see getElement() in HTMLElements.java
87
+ HTMLElements .Element elem = htmlElements_ .getElement (name .asJavaString (), htmlElements_ .NO_SUCH_ELEMENT );
88
+ if (elem == htmlElements_ .NO_SUCH_ELEMENT ) {
90
89
return context .nil ;
91
90
}
92
91
0 commit comments