mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 19:29:18 +02:00
* Replaces several direct references to FNSI.QName by the NodeName property, so
that descendent classes can override the NodeName properly * Fixed an AV when GetNodeName is called and there is no NodeName set * Removed the THtmlCustomElement.NodeName property and override the GetNodeName method instead. The hashtable of TDOMNode_NS is not used because THtmlCustomElement uses a faster lookupsystem for tag/node-names * Added a basic test for the htmlwriter unit git-svn-id: trunk@12732 -
This commit is contained in:
parent
e038d87411
commit
a2f5f7400b
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -7696,6 +7696,7 @@ tests/test/packages/fcl-db/tdb4.pp svneol=native#text/plain
|
||||
tests/test/packages/fcl-db/tdb5.pp svneol=native#text/plain
|
||||
tests/test/packages/fcl-db/toolsunit.pas svneol=native#text/plain
|
||||
tests/test/packages/fcl-registry/tregistry1.pp svneol=native#text/plain
|
||||
tests/test/packages/fcl-xml/thtmlwriter.pp svneol=native#text/plain
|
||||
tests/test/packages/hash/tmdtest.pp svneol=native#text/plain
|
||||
tests/test/packages/webtbs/tw10045.pp svneol=native#text/plain
|
||||
tests/test/packages/webtbs/tw11142.pp svneol=native#text/plain
|
||||
|
@ -2080,7 +2080,13 @@ end;
|
||||
|
||||
function TDOMNode_NS.GetNodeName: DOMString;
|
||||
begin
|
||||
Result := FNSI.QName^.Key;
|
||||
// Because FNSI.QName is not set by the TDOMNode itself, but is set by
|
||||
// other classes/functions, it is necessary to check if FNSQ.QName is
|
||||
// assigned.
|
||||
if assigned(FNSI.QName) then
|
||||
Result := FNSI.QName^.Key
|
||||
else
|
||||
Result := '';
|
||||
end;
|
||||
|
||||
function TDOMNode_NS.GetLocalName: DOMString;
|
||||
@ -2126,7 +2132,7 @@ end;
|
||||
|
||||
function TDOMNode_NS.CompareName(const AName: DOMString): Integer;
|
||||
begin
|
||||
Result := CompareDOMStrings(DOMPChar(AName), DOMPChar(FNSI.QName^.Key), Length(AName), Length(FNSI.QName^.Key));
|
||||
Result := CompareDOMStrings(DOMPChar(AName), DOMPChar(NodeName), Length(AName), Length(NodeName));
|
||||
end;
|
||||
|
||||
// -------------------------------------------------------
|
||||
@ -2141,7 +2147,7 @@ end;
|
||||
function TDOMAttr.CloneNode(deep: Boolean; ACloneOwner: TDOMDocument): TDOMNode;
|
||||
begin
|
||||
// Cloned attribute is always specified and carries its children
|
||||
Result := ACloneOwner.CreateAttribute(FNSI.QName^.Key);
|
||||
Result := ACloneOwner.CreateAttribute(NodeName);
|
||||
TDOMAttr(Result).FDataType := FDataType;
|
||||
CloneChildren(Result, ACloneOwner);
|
||||
end;
|
||||
@ -2186,7 +2192,7 @@ function TDOMElement.CloneNode(deep: Boolean; ACloneOwner: TDOMDocument): TDOMNo
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Result := ACloneOwner.CreateElement(FNSI.QName^.Key);
|
||||
Result := ACloneOwner.CreateElement(NodeName);
|
||||
if Assigned(FAttributes) then
|
||||
begin
|
||||
for i := 0 to FAttributes.Length - 1 do
|
||||
|
@ -35,6 +35,7 @@ type
|
||||
procedure WriteAttributes (const aStream : TStream);
|
||||
procedure WriteSubNodes (const aStream : TStream);
|
||||
protected
|
||||
function GetNodeName: DOMString; override;
|
||||
procedure StringToStream (const aStream : TStream; s : string);
|
||||
procedure StringToStream (const aStream : TStream; Fmt : string; Args : array of const);
|
||||
function EscapeString (s : string) : string;
|
||||
@ -50,7 +51,6 @@ type
|
||||
|
||||
property ElementTag : THTMLElementTag read FElementTag write FElementTag;
|
||||
property TagName : DOMString read GetTagName;
|
||||
property NodeName : DOMstring read GetTagName;
|
||||
property AttributeNames [index:integer] : DOMString read GetAttributeName;
|
||||
property AttributeValues [index:integer] : DOMString read GetAttributeValue;
|
||||
end;
|
||||
@ -182,6 +182,11 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function THtmlCustomElement.GetNodeName: DOMString;
|
||||
begin
|
||||
Result:=GetTagName;
|
||||
end;
|
||||
|
||||
procedure THtmlCustomElement.StringToStream(const aStream: TStream; s: string);
|
||||
begin
|
||||
if s <> '' then
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Don't edit, this file is generated by FPCMake Version 2.0.0 [2009/01/31]
|
||||
# Don't edit, this file is generated by FPCMake Version 2.0.0 [2009/02/09]
|
||||
#
|
||||
default: allexectests
|
||||
MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded
|
||||
@ -1443,7 +1443,7 @@ ifndef LOG
|
||||
export LOG:=$(TEST_OUTPUTDIR)/log
|
||||
endif
|
||||
TESTSUBDIRS=cg cg/variants cg/cdecl opt units/system units/dos units/crt units/objects units/strings units/sysutils units/math units/sharemem
|
||||
TESTPACKAGESUBDIRS=cg packages/win-base packages/webtbs packages/hash packages/fcl-registry packages/fcl-process packages/zlib packages/fcl-db packages/fcl-base
|
||||
TESTPACKAGESUBDIRS=cg packages/win-base packages/webtbs packages/hash packages/fcl-registry packages/fcl-process packages/zlib packages/fcl-db packages/fcl-base packages/fcl-xml
|
||||
ifdef QUICKTEST
|
||||
export QUICKTEST
|
||||
else
|
||||
|
@ -120,7 +120,7 @@ endif
|
||||
|
||||
# Subdirs available in the test subdir
|
||||
TESTSUBDIRS=cg cg/variants cg/cdecl opt units/system units/dos units/crt units/objects units/strings units/sysutils units/math units/sharemem
|
||||
TESTPACKAGESUBDIRS=cg packages/win-base packages/webtbs packages/hash packages/fcl-registry packages/fcl-process packages/zlib packages/fcl-db packages/fcl-base
|
||||
TESTPACKAGESUBDIRS=cg packages/win-base packages/webtbs packages/hash packages/fcl-registry packages/fcl-process packages/zlib packages/fcl-db packages/fcl-base packages/fcl-xml
|
||||
|
||||
ifdef QUICKTEST
|
||||
export QUICKTEST
|
||||
|
26
tests/test/packages/fcl-xml/thtmlwriter.pp
Normal file
26
tests/test/packages/fcl-xml/thtmlwriter.pp
Normal file
@ -0,0 +1,26 @@
|
||||
program TestHtmlWriter;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
Classes, SysUtils, htmlwriter, htmlelements;
|
||||
|
||||
var hwriter: THtmlWriter;
|
||||
hdoc : THTMLDocument;
|
||||
begin
|
||||
hdoc := THTMLDocument.Create;
|
||||
hwriter := THTMLwriter.create(hdoc);
|
||||
hwriter.Starthtml;
|
||||
hwriter.Starthead;
|
||||
hwriter.title('Test website');
|
||||
hwriter.Endhead;
|
||||
hwriter.Startbody;
|
||||
hwriter.paragraph('test line 1');
|
||||
hwriter.paragraph('test line 2');
|
||||
hwriter.Endbody;
|
||||
hwriter.Endhtml;
|
||||
hwriter.Free;
|
||||
writeln(hdoc.Asstring);
|
||||
hdoc.Free;
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user