Permalink
Browse files

Fix createEntityReference to behave correctly when the document has n…

…o doctype (fixes failing test case nodenormalize01).
  • Loading branch information...
1 parent e90346d commit 8ea016668486f34c130990ea4cea8686a2e7d854 @djcsdy djcsdy committed Feb 7, 2011
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/jsdom/level1/core.js
@@ -1350,8 +1350,14 @@ core.Document.prototype = {
throw new core.DOMException(INVALID_CHARACTER_ERR);
}
- var entity = this._doctype.entities.getNamedItem(name),
- ref = new core.EntityReference(this, entity);
+ var entity;
+ if (this._doctype && this._doctype.entities) {
+ entity = this._doctype.entities.getNamedItem(name);
+ } else {
+ entity = null;
+ }
+
+ var ref = new core.EntityReference(this, entity);
ref._entityName = name;

0 comments on commit 8ea0166

Please sign in to comment.