|
@@ -38,7 +38,7 @@ unit DOM;
|
|
interface
|
|
interface
|
|
|
|
|
|
uses
|
|
uses
|
|
- SysUtils, Classes, AVL_Tree;
|
|
|
|
|
|
+ SysUtils, Classes, AVL_Tree, xmlutils;
|
|
|
|
|
|
// -------------------------------------------------------
|
|
// -------------------------------------------------------
|
|
// DOMException
|
|
// DOMException
|
|
@@ -221,6 +221,8 @@ type
|
|
function GetPrefix: DOMString; virtual;
|
|
function GetPrefix: DOMString; virtual;
|
|
procedure SetPrefix(const Value: DOMString); virtual;
|
|
procedure SetPrefix(const Value: DOMString); virtual;
|
|
function GetOwnerDocument: TDOMDocument; virtual;
|
|
function GetOwnerDocument: TDOMDocument; virtual;
|
|
|
|
+ procedure SetReadOnly(Value: Boolean);
|
|
|
|
+ procedure Changing;
|
|
public
|
|
public
|
|
constructor Create(AOwner: TDOMDocument);
|
|
constructor Create(AOwner: TDOMDocument);
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
@@ -299,7 +301,7 @@ type
|
|
protected
|
|
protected
|
|
FNode: TDOMNode;
|
|
FNode: TDOMNode;
|
|
FRevision: Integer;
|
|
FRevision: Integer;
|
|
- FList: TList;
|
|
|
|
|
|
+ FList: TFPList;
|
|
function GetCount: LongWord;
|
|
function GetCount: LongWord;
|
|
function GetItem(index: LongWord): TDOMNode;
|
|
function GetItem(index: LongWord): TDOMNode;
|
|
procedure BuildList; virtual;
|
|
procedure BuildList; virtual;
|
|
@@ -333,7 +335,7 @@ type
|
|
protected
|
|
protected
|
|
FOwner: TDOMNode;
|
|
FOwner: TDOMNode;
|
|
FNodeType: Integer;
|
|
FNodeType: Integer;
|
|
- FList: TList;
|
|
|
|
|
|
+ FList: TFPList;
|
|
function GetItem(index: LongWord): TDOMNode;
|
|
function GetItem(index: LongWord): TDOMNode;
|
|
function GetLength: LongWord;
|
|
function GetLength: LongWord;
|
|
function Find(const name: DOMString; out Index: LongWord): Boolean;
|
|
function Find(const name: DOMString; out Index: LongWord): Boolean;
|
|
@@ -415,7 +417,7 @@ type
|
|
|
|
|
|
TDOMDocument = class(TDOMNode_WithChildren)
|
|
TDOMDocument = class(TDOMNode_WithChildren)
|
|
protected
|
|
protected
|
|
- FIDList: TList;
|
|
|
|
|
|
+ FIDList: THashTable;
|
|
FRevision: Integer;
|
|
FRevision: Integer;
|
|
FXML11: Boolean;
|
|
FXML11: Boolean;
|
|
FImplementation: TDOMImplementation;
|
|
FImplementation: TDOMImplementation;
|
|
@@ -427,8 +429,6 @@ type
|
|
function GetOwnerDocument: TDOMDocument; override;
|
|
function GetOwnerDocument: TDOMDocument; override;
|
|
procedure SetTextContent(const value: DOMString); override;
|
|
procedure SetTextContent(const value: DOMString); override;
|
|
function IndexOfNS(const nsURI: DOMString): Integer;
|
|
function IndexOfNS(const nsURI: DOMString): Integer;
|
|
- function FindID(const aID: DOMString; out Index: LongWord): Boolean;
|
|
|
|
- procedure ClearIDList;
|
|
|
|
procedure RemoveID(Elem: TDOMElement);
|
|
procedure RemoveID(Elem: TDOMElement);
|
|
public
|
|
public
|
|
property DocType: TDOMDocumentType read GetDocType;
|
|
property DocType: TDOMDocumentType read GetDocType;
|
|
@@ -713,16 +713,6 @@ type
|
|
|
|
|
|
implementation
|
|
implementation
|
|
|
|
|
|
-uses
|
|
|
|
- xmlutils;
|
|
|
|
-
|
|
|
|
-type
|
|
|
|
- PIDItem = ^TIDItem;
|
|
|
|
- TIDItem = record
|
|
|
|
- ID: WideString;
|
|
|
|
- Element: TDOMElement;
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
constructor TRefClass.Create;
|
|
constructor TRefClass.Create;
|
|
begin
|
|
begin
|
|
inherited Create;
|
|
inherited Create;
|
|
@@ -858,12 +848,14 @@ end;
|
|
|
|
|
|
function TDOMNode.InsertBefore(NewChild, RefChild: TDOMNode): TDOMNode;
|
|
function TDOMNode.InsertBefore(NewChild, RefChild: TDOMNode): TDOMNode;
|
|
begin
|
|
begin
|
|
|
|
+ Changing; // merely to comply with core3/nodeinsertbefore14
|
|
raise EDOMHierarchyRequest.Create('Node.InsertBefore');
|
|
raise EDOMHierarchyRequest.Create('Node.InsertBefore');
|
|
Result:=nil;
|
|
Result:=nil;
|
|
end;
|
|
end;
|
|
|
|
|
|
function TDOMNode.ReplaceChild(NewChild, OldChild: TDOMNode): TDOMNode;
|
|
function TDOMNode.ReplaceChild(NewChild, OldChild: TDOMNode): TDOMNode;
|
|
begin
|
|
begin
|
|
|
|
+ Changing; // merely to comply with core3/nodereplacechild21
|
|
raise EDOMHierarchyRequest.Create('Node.ReplaceChild');
|
|
raise EDOMHierarchyRequest.Create('Node.ReplaceChild');
|
|
Result:=nil;
|
|
Result:=nil;
|
|
end;
|
|
end;
|
|
@@ -1000,6 +992,36 @@ begin
|
|
Result := FOwnerDocument;
|
|
Result := FOwnerDocument;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TDOMNode.SetReadOnly(Value: Boolean);
|
|
|
|
+var
|
|
|
|
+ child: TDOMNode;
|
|
|
|
+ attrs: TDOMNamedNodeMap;
|
|
|
|
+ I: Integer;
|
|
|
|
+begin
|
|
|
|
+ if Value then
|
|
|
|
+ Include(FFlags, nfReadOnly)
|
|
|
|
+ else
|
|
|
|
+ Exclude(FFlags, nfReadOnly);
|
|
|
|
+ child := FirstChild;
|
|
|
|
+ while Assigned(child) do
|
|
|
|
+ begin
|
|
|
|
+ child.SetReadOnly(Value);
|
|
|
|
+ child := child.NextSibling;
|
|
|
|
+ end;
|
|
|
|
+ attrs := Attributes;
|
|
|
|
+ if Assigned(attrs) then
|
|
|
|
+ begin
|
|
|
|
+ for I := 0 to attrs.Length-1 do
|
|
|
|
+ attrs[I].SetReadOnly(Value);
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TDOMNode.Changing;
|
|
|
|
+begin
|
|
|
|
+ if nfReadOnly in FFlags then
|
|
|
|
+ raise EDOMError.Create(NO_MODIFICATION_ALLOWED_ERR, 'Node.CheckReadOnly');
|
|
|
|
+end;
|
|
|
|
+
|
|
function CompareDOMStrings(const s1, s2: DOMPChar; l1, l2: integer): integer;
|
|
function CompareDOMStrings(const s1, s2: DOMPChar; l1, l2: integer): integer;
|
|
var i: integer;
|
|
var i: integer;
|
|
begin
|
|
begin
|
|
@@ -1082,6 +1104,7 @@ begin
|
|
Result := NewChild;
|
|
Result := NewChild;
|
|
NewChildType := NewChild.NodeType;
|
|
NewChildType := NewChild.NodeType;
|
|
|
|
|
|
|
|
+ Changing;
|
|
if NewChild.FOwnerDocument <> FOwnerDocument then
|
|
if NewChild.FOwnerDocument <> FOwnerDocument then
|
|
begin
|
|
begin
|
|
if (NewChildType <> DOCUMENT_TYPE_NODE) or
|
|
if (NewChildType <> DOCUMENT_TYPE_NODE) or
|
|
@@ -1171,6 +1194,8 @@ end;
|
|
|
|
|
|
function TDOMNode_WithChildren.DetachChild(OldChild: TDOMNode): TDOMNode;
|
|
function TDOMNode_WithChildren.DetachChild(OldChild: TDOMNode): TDOMNode;
|
|
begin
|
|
begin
|
|
|
|
+ Changing;
|
|
|
|
+
|
|
if OldChild.ParentNode <> Self then
|
|
if OldChild.ParentNode <> Self then
|
|
raise EDOMNotFound.Create('NodeWC.RemoveChild');
|
|
raise EDOMNotFound.Create('NodeWC.RemoveChild');
|
|
|
|
|
|
@@ -1266,6 +1291,7 @@ end;
|
|
|
|
|
|
procedure TDOMNode_WithChildren.SetTextContent(const AValue: DOMString);
|
|
procedure TDOMNode_WithChildren.SetTextContent(const AValue: DOMString);
|
|
begin
|
|
begin
|
|
|
|
+ Changing;
|
|
FreeChildren;
|
|
FreeChildren;
|
|
if AValue <> '' then
|
|
if AValue <> '' then
|
|
AppendChild(FOwnerDocument.CreateTextNode(AValue));
|
|
AppendChild(FOwnerDocument.CreateTextNode(AValue));
|
|
@@ -1295,7 +1321,7 @@ begin
|
|
inherited Create;
|
|
inherited Create;
|
|
FNode := ANode;
|
|
FNode := ANode;
|
|
FRevision := ANode.GetRevision-1; // force BuildList at first access
|
|
FRevision := ANode.GetRevision-1; // force BuildList at first access
|
|
- FList := TList.Create;
|
|
|
|
|
|
+ FList := TFPList.Create;
|
|
end;
|
|
end;
|
|
|
|
|
|
destructor TDOMNodeList.Destroy;
|
|
destructor TDOMNodeList.Destroy;
|
|
@@ -1395,7 +1421,7 @@ begin
|
|
inherited Create;
|
|
inherited Create;
|
|
FOwner := AOwner;
|
|
FOwner := AOwner;
|
|
FNodeType := ANodeType;
|
|
FNodeType := ANodeType;
|
|
- FList := TList.Create;
|
|
|
|
|
|
+ FList := TFPList.Create;
|
|
end;
|
|
end;
|
|
|
|
|
|
destructor TDOMNamedNodeMap.Destroy;
|
|
destructor TDOMNamedNodeMap.Destroy;
|
|
@@ -1467,7 +1493,9 @@ var
|
|
AttrOwner: TDOMNode;
|
|
AttrOwner: TDOMNode;
|
|
begin
|
|
begin
|
|
Result := 0;
|
|
Result := 0;
|
|
- if arg.FOwnerDocument <> FOwner.FOwnerDocument then
|
|
|
|
|
|
+ if nfReadOnly in FOwner.FFlags then
|
|
|
|
+ Result := NO_MODIFICATION_ALLOWED_ERR
|
|
|
|
+ else if arg.FOwnerDocument <> FOwner.FOwnerDocument then
|
|
Result := WRONG_DOCUMENT_ERR
|
|
Result := WRONG_DOCUMENT_ERR
|
|
else if arg.NodeType <> FNodeType then
|
|
else if arg.NodeType <> FNodeType then
|
|
Result := HIERARCHY_REQUEST_ERR
|
|
Result := HIERARCHY_REQUEST_ERR
|
|
@@ -1537,6 +1565,8 @@ end;
|
|
|
|
|
|
function TDOMNamedNodeMap.RemoveNamedItem(const name: DOMString): TDOMNode;
|
|
function TDOMNamedNodeMap.RemoveNamedItem(const name: DOMString): TDOMNode;
|
|
begin
|
|
begin
|
|
|
|
+ if nfReadOnly in FOwner.FFlags then
|
|
|
|
+ raise EDOMError.Create(NO_MODIFICATION_ALLOWED_ERR, 'NamedNodeMap.RemoveNamedItem');
|
|
Result := InternalRemove(name);
|
|
Result := InternalRemove(name);
|
|
if Result = nil then
|
|
if Result = nil then
|
|
raise EDOMNotFound.Create('NamedNodeMap.RemoveNamedItem');
|
|
raise EDOMNotFound.Create('NamedNodeMap.RemoveNamedItem');
|
|
@@ -1544,6 +1574,8 @@ end;
|
|
|
|
|
|
function TDOMNamedNodeMap.RemoveNamedItemNS(const namespaceURI, localName: DOMString): TDOMNode;
|
|
function TDOMNamedNodeMap.RemoveNamedItemNS(const namespaceURI, localName: DOMString): TDOMNode;
|
|
begin
|
|
begin
|
|
|
|
+ if nfReadOnly in FOwner.FFlags then
|
|
|
|
+ raise EDOMError.Create(NO_MODIFICATION_ALLOWED_ERR, 'NamedNodeMap.RemoveNamedItemNS');
|
|
// TODO: Implement TDOMNamedNodeMap.RemoveNamedItemNS
|
|
// TODO: Implement TDOMNamedNodeMap.RemoveNamedItemNS
|
|
Result := nil;
|
|
Result := nil;
|
|
end;
|
|
end;
|
|
@@ -1565,6 +1597,7 @@ end;
|
|
|
|
|
|
procedure TDOMCharacterData.SetNodeValue(const AValue: DOMString);
|
|
procedure TDOMCharacterData.SetNodeValue(const AValue: DOMString);
|
|
begin
|
|
begin
|
|
|
|
+ Changing;
|
|
FNodeValue := AValue;
|
|
FNodeValue := AValue;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -1577,11 +1610,13 @@ end;
|
|
|
|
|
|
procedure TDOMCharacterData.AppendData(const arg: DOMString);
|
|
procedure TDOMCharacterData.AppendData(const arg: DOMString);
|
|
begin
|
|
begin
|
|
|
|
+ Changing;
|
|
FNodeValue := FNodeValue + arg;
|
|
FNodeValue := FNodeValue + arg;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TDOMCharacterData.InsertData(offset: LongWord; const arg: DOMString);
|
|
procedure TDOMCharacterData.InsertData(offset: LongWord; const arg: DOMString);
|
|
begin
|
|
begin
|
|
|
|
+ Changing;
|
|
if offset > Length then
|
|
if offset > Length then
|
|
raise EDOMIndexSize.Create('CharacterData.InsertData');
|
|
raise EDOMIndexSize.Create('CharacterData.InsertData');
|
|
Insert(arg, FNodeValue, offset+1);
|
|
Insert(arg, FNodeValue, offset+1);
|
|
@@ -1589,6 +1624,7 @@ end;
|
|
|
|
|
|
procedure TDOMCharacterData.DeleteData(offset, count: LongWord);
|
|
procedure TDOMCharacterData.DeleteData(offset, count: LongWord);
|
|
begin
|
|
begin
|
|
|
|
+ Changing;
|
|
if offset > Length then
|
|
if offset > Length then
|
|
raise EDOMIndexSize.Create('CharacterData.DeleteData');
|
|
raise EDOMIndexSize.Create('CharacterData.DeleteData');
|
|
Delete(FNodeValue, offset+1, count);
|
|
Delete(FNodeValue, offset+1, count);
|
|
@@ -1685,86 +1721,61 @@ end;
|
|
|
|
|
|
destructor TDOMDocument.Destroy;
|
|
destructor TDOMDocument.Destroy;
|
|
begin
|
|
begin
|
|
- ClearIDList;
|
|
|
|
FreeAndNil(FIDList); // set to nil before starting destroying chidlren
|
|
FreeAndNil(FIDList); // set to nil before starting destroying chidlren
|
|
inherited Destroy;
|
|
inherited Destroy;
|
|
end;
|
|
end;
|
|
|
|
|
|
function TDOMDocument.AddID(Attr: TDOMAttr): Boolean;
|
|
function TDOMDocument.AddID(Attr: TDOMAttr): Boolean;
|
|
var
|
|
var
|
|
- I: Cardinal;
|
|
|
|
- Item: PIDItem;
|
|
|
|
|
|
+ ID: DOMString;
|
|
|
|
+ Exists: Boolean;
|
|
|
|
+ p: PHashItem;
|
|
begin
|
|
begin
|
|
if FIDList = nil then
|
|
if FIDList = nil then
|
|
- FIDList := TList.Create;
|
|
|
|
- New(Item);
|
|
|
|
- Item^.ID := Attr.Value;
|
|
|
|
- Item^.Element := Attr.OwnerElement;
|
|
|
|
- if not FindID(Item^.ID, I) then
|
|
|
|
|
|
+ FIDList := THashTable.Create(256, False);
|
|
|
|
+
|
|
|
|
+ ID := Attr.Value;
|
|
|
|
+ p := FIDList.FindOrAdd(DOMPChar(ID), Length(ID), Exists);
|
|
|
|
+ if not Exists then
|
|
begin
|
|
begin
|
|
- FIDList.Insert(I, Item);
|
|
|
|
|
|
+ p^.Data := Attr.OwnerElement;
|
|
Result := True;
|
|
Result := True;
|
|
end
|
|
end
|
|
else
|
|
else
|
|
- begin
|
|
|
|
- Dispose(Item);
|
|
|
|
Result := False;
|
|
Result := False;
|
|
- end;
|
|
|
|
end;
|
|
end;
|
|
|
|
|
|
// This shouldn't be called if document has no IDs,
|
|
// This shouldn't be called if document has no IDs,
|
|
// or when it is being destroyed
|
|
// or when it is being destroyed
|
|
-procedure TDOMDocument.RemoveID(Elem: TDOMElement);
|
|
|
|
-var
|
|
|
|
- I: Integer;
|
|
|
|
-begin
|
|
|
|
- for I := 0 to FIDList.Count-1 do
|
|
|
|
- begin
|
|
|
|
- if PIDItem(FIDList.List^[I])^.Element = Elem then
|
|
|
|
- begin
|
|
|
|
- Dispose(PIDItem(FIDList.List^[I]));
|
|
|
|
- FIDList.Delete(I);
|
|
|
|
- Exit;
|
|
|
|
- end;
|
|
|
|
|
|
+// TODO: This could be much faster if removing ID happens
|
|
|
|
+// upon modification of corresponding attribute value.
|
|
|
|
+
|
|
|
|
+type
|
|
|
|
+ TempRec = record
|
|
|
|
+ Element: TDOMElement;
|
|
|
|
+ Entry: PHashItem;
|
|
end;
|
|
end;
|
|
-end;
|
|
|
|
|
|
|
|
-function TDOMDocument.FindID(const aID: DOMString; out Index: LongWord): Boolean;
|
|
|
|
-var
|
|
|
|
- L, H, I, C: Integer;
|
|
|
|
- P: PIDItem;
|
|
|
|
|
|
+function CheckID(Entry: PHashItem; arg: Pointer): Boolean;
|
|
begin
|
|
begin
|
|
- Result := False;
|
|
|
|
- L := 0;
|
|
|
|
- H := FIDList.Count - 1;
|
|
|
|
- while L <= H do
|
|
|
|
|
|
+ if Entry^.Data = TempRec(arg^).Element then
|
|
begin
|
|
begin
|
|
- I := (L + H) shr 1;
|
|
|
|
- P := PIDItem(FIDList.List^[I]);
|
|
|
|
- C := CompareDOMStrings(PWideChar(aID), PWideChar(P^.ID), Length(aID), Length(P^.ID));
|
|
|
|
- if C > 0 then L := I + 1 else
|
|
|
|
- begin
|
|
|
|
- H := I - 1;
|
|
|
|
- if C = 0 then
|
|
|
|
- begin
|
|
|
|
- Result := True;
|
|
|
|
- L := I;
|
|
|
|
- end;
|
|
|
|
- end;
|
|
|
|
- end;
|
|
|
|
- Index := L;
|
|
|
|
|
|
+ TempRec(arg^).Entry := Entry;
|
|
|
|
+ Result := False;
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ Result := True;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TDOMDocument.ClearIDList;
|
|
|
|
|
|
+procedure TDOMDocument.RemoveID(Elem: TDOMElement);
|
|
var
|
|
var
|
|
- I: Integer;
|
|
|
|
|
|
+ hr: TempRec;
|
|
begin
|
|
begin
|
|
- if Assigned(FIDList) then
|
|
|
|
- begin
|
|
|
|
- for I := 0 to FIDList.Count-1 do
|
|
|
|
- Dispose(PIDItem(FIDList.List^[I]));
|
|
|
|
- FIDList.Clear;
|
|
|
|
- end;
|
|
|
|
|
|
+ hr.Element := Elem;
|
|
|
|
+ hr.Entry := nil;
|
|
|
|
+ FIDList.ForEach(@CheckID, @hr);
|
|
|
|
+ if Assigned(hr.Entry) then
|
|
|
|
+ FIDList.Remove(hr.Entry);
|
|
end;
|
|
end;
|
|
|
|
|
|
function TDOMDocument.GetNodeType: Integer;
|
|
function TDOMDocument.GetNodeType: Integer;
|
|
@@ -1924,13 +1935,10 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
function TDOMDocument.GetElementById(const ElementID: DOMString): TDOMElement;
|
|
function TDOMDocument.GetElementById(const ElementID: DOMString): TDOMElement;
|
|
-var
|
|
|
|
- I: Cardinal;
|
|
|
|
begin
|
|
begin
|
|
- if Assigned(FIDList) and FindID(ElementID, I) then
|
|
|
|
- Result := PIDItem(FIDList.List^[I])^.Element
|
|
|
|
- else
|
|
|
|
Result := nil;
|
|
Result := nil;
|
|
|
|
+ if Assigned(FIDList) then
|
|
|
|
+ Result := TDOMElement(FIDList.Get(DOMPChar(ElementID), Length(ElementID)));
|
|
end;
|
|
end;
|
|
|
|
|
|
function TDOMDocument.ImportNode(ImportedNode: TDOMNode;
|
|
function TDOMDocument.ImportNode(ImportedNode: TDOMNode;
|
|
@@ -1980,6 +1988,7 @@ begin
|
|
if Assigned(ent) then
|
|
if Assigned(ent) then
|
|
ent.CloneChildren(Result, Self);
|
|
ent.CloneChildren(Result, Self);
|
|
end;
|
|
end;
|
|
|
|
+ Result.SetReadOnly(True);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TXMLDocument.SetXMLVersion(const aValue: DOMString);
|
|
procedure TXMLDocument.SetXMLVersion(const aValue: DOMString);
|
|
@@ -2119,6 +2128,7 @@ var
|
|
I: Cardinal;
|
|
I: Cardinal;
|
|
attr: TDOMAttr;
|
|
attr: TDOMAttr;
|
|
begin
|
|
begin
|
|
|
|
+ Changing;
|
|
if Attributes.Find(name, I) then
|
|
if Attributes.Find(name, I) then
|
|
Attr := FAttributes[I] as TDOMAttr
|
|
Attr := FAttributes[I] as TDOMAttr
|
|
else
|
|
else
|
|
@@ -2132,6 +2142,7 @@ end;
|
|
|
|
|
|
procedure TDOMElement.RemoveAttribute(const name: DOMString);
|
|
procedure TDOMElement.RemoveAttribute(const name: DOMString);
|
|
begin
|
|
begin
|
|
|
|
+ Changing;
|
|
// (note) NamedNodeMap.RemoveNamedItem can raise NOT_FOUND_ERR and we should not.
|
|
// (note) NamedNodeMap.RemoveNamedItem can raise NOT_FOUND_ERR and we should not.
|
|
if Assigned(FAttributes) then
|
|
if Assigned(FAttributes) then
|
|
FAttributes.InternalRemove(name).Free;
|
|
FAttributes.InternalRemove(name).Free;
|
|
@@ -2140,6 +2151,7 @@ end;
|
|
procedure TDOMElement.RemoveAttributeNS(const nsURI,
|
|
procedure TDOMElement.RemoveAttributeNS(const nsURI,
|
|
aLocalName: DOMString);
|
|
aLocalName: DOMString);
|
|
begin
|
|
begin
|
|
|
|
+ Changing;
|
|
// TODO: Implement TDOMElement.RemoveAttributeNS
|
|
// TODO: Implement TDOMElement.RemoveAttributeNS
|
|
raise EDOMNotSupported.Create('TDOMElement.RemoveAttributeNS');
|
|
raise EDOMNotSupported.Create('TDOMElement.RemoveAttributeNS');
|
|
end;
|
|
end;
|
|
@@ -2202,14 +2214,18 @@ end;
|
|
|
|
|
|
function TDOMElement.RemoveAttributeNode(OldAttr: TDOMAttr): TDOMAttr;
|
|
function TDOMElement.RemoveAttributeNode(OldAttr: TDOMAttr): TDOMAttr;
|
|
begin
|
|
begin
|
|
|
|
+ Changing;
|
|
Result:=nil;
|
|
Result:=nil;
|
|
- if FAttributes=nil then exit;
|
|
|
|
// TODO: DOM 2: must raise NOT_FOUND_ERR if OldAttr is not ours.
|
|
// TODO: DOM 2: must raise NOT_FOUND_ERR if OldAttr is not ours.
|
|
// -- but what is the purpose of return value then?
|
|
// -- but what is the purpose of return value then?
|
|
// TODO: delegate to TNamedNodeMap? Nope, it does not have such method
|
|
// TODO: delegate to TNamedNodeMap? Nope, it does not have such method
|
|
// (note) one way around is to remove by name
|
|
// (note) one way around is to remove by name
|
|
- if FAttributes.FList.Remove(OldAttr) > -1 then
|
|
|
|
|
|
+ if Assigned(FAttributes) and (FAttributes.FList.Remove(OldAttr) > -1) then
|
|
|
|
+ begin
|
|
Result := OldAttr;
|
|
Result := OldAttr;
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ raise EDOMNotFound.Create('Element.RemoveAttributeNode');
|
|
end;
|
|
end;
|
|
|
|
|
|
function TDOMElement.GetElementsByTagName(const name: DOMString): TDOMNodeList;
|
|
function TDOMElement.GetElementsByTagName(const name: DOMString): TDOMNodeList;
|
|
@@ -2418,6 +2434,7 @@ begin
|
|
TDOMEntity(Result).FNotationName := FNotationName;
|
|
TDOMEntity(Result).FNotationName := FNotationName;
|
|
if deep then
|
|
if deep then
|
|
CloneChildren(Result, aCloneOwner);
|
|
CloneChildren(Result, aCloneOwner);
|
|
|
|
+ Result.SetReadOnly(True);
|
|
end;
|
|
end;
|
|
|
|
|
|
// -------------------------------------------------------
|
|
// -------------------------------------------------------
|
|
@@ -2466,6 +2483,7 @@ end;
|
|
|
|
|
|
procedure TDOMProcessingInstruction.SetNodeValue(const AValue: DOMString);
|
|
procedure TDOMProcessingInstruction.SetNodeValue(const AValue: DOMString);
|
|
begin
|
|
begin
|
|
|
|
+ Changing;
|
|
FNodeValue := AValue;
|
|
FNodeValue := AValue;
|
|
end;
|
|
end;
|
|
|
|
|