Commit 330c744c authored by Andrea Iacovitti's avatar Andrea Iacovitti

document.createEntityReference()

Raise NOT_SUPPORTED_ERR exception if document is an HTML document.
Test page at http://dbaron.org/dom/test/one-core-html/exceptions
parent 2887b70a
......@@ -305,8 +305,15 @@ Attr Document::createAttributeNS( const DOMString &namespaceURI, const DOMString
EntityReference Document::createEntityReference( const DOMString &name )
{
if (impl) return ((DocumentImpl *)impl)->createEntityReference( name );
return 0;
if (!impl) {
return 0;
}
int exceptioncode = 0;
EntityReferenceImpl *er = ((DocumentImpl *)impl)->createEntityReference(name, exceptioncode);
if (exceptioncode) {
throw DOMException(exceptioncode);
}
return er;
}
Element Document::getElementById( const DOMString &elementId ) const
......
......@@ -1106,7 +1106,7 @@ JSValue* DOMDocumentProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj
case DOMDocument::CreateAttribute:
return getDOMNode(exec,doc.createAttribute(s, exception));
case DOMDocument::CreateEntityReference:
return getDOMNode(exec,doc.createEntityReference(args[0]->toString(exec).domString()));
return getDOMNode(exec,doc.createEntityReference(args[0]->toString(exec).domString(), exception));
case DOMDocument::GetElementsByTagName:
return getDOMNodeList(exec,doc.getElementsByTagName(s));
case DOMDocument::ImportNode: // DOM2
......
......@@ -653,8 +653,12 @@ ProcessingInstructionImpl *DocumentImpl::createProcessingInstruction ( const DOM
return new ProcessingInstructionImpl( docPtr(),target,data);
}
EntityReferenceImpl *DocumentImpl::createEntityReference ( const DOMString &name )
EntityReferenceImpl *DocumentImpl::createEntityReference ( const DOMString &name, int &exceptioncode )
{
if (isHTMLDocument()) {
exceptioncode = DOMException::NOT_SUPPORTED_ERR;
return 0;
}
return new EntityReferenceImpl(docPtr(), name.implementation());
}
......@@ -710,7 +714,7 @@ NodeImpl *DocumentImpl::importNode(NodeImpl *importedNode, bool deep, int &excep
deep = false;
}
else if(importedNode->nodeType() == Node::ENTITY_REFERENCE_NODE)
result = createEntityReference(importedNode->nodeName());
result = createEntityReference(importedNode->nodeName(), exceptioncode);
else if(importedNode->nodeType() == Node::PROCESSING_INSTRUCTION_NODE)
{
result = createProcessingInstruction(importedNode->nodeName(), importedNode->nodeValue().implementation());
......
......@@ -220,7 +220,7 @@ public:
CommentImpl *createComment ( DOMStringImpl* data );
CDATASectionImpl *createCDATASection ( DOMStringImpl* data, int &exceptioncode );
ProcessingInstructionImpl *createProcessingInstruction ( const DOMString &target, DOMStringImpl* data );
EntityReferenceImpl *createEntityReference ( const DOMString &name );
EntityReferenceImpl *createEntityReference ( const DOMString &name, int &exceptioncode );
NodeImpl *importNode( NodeImpl *importedNode, bool deep, int &exceptioncode );
virtual ElementImpl *createElementNS ( const DOMString &_namespaceURI, const DOMString &_qualifiedName,
int* pExceptioncode = 0 );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment