You are not logged in.
Pages: 1
This line seems to work:
Result := TempObject.AsSMValue.ToVariant(TempObject.cx);
Hello,
First of all, thank you for mORMot -- I'm not yet super familiar with it, but it seems to be an impressive piece of work. I have so far only contributed to ticket 125fc8d280633be2b8a983b7160f9fba1df114f8, but I hope this will change. ^^
So, I'm using SynSM to run the following dummy JS code:
alert(document.createElement("testNode").nodeName);
I have declared window as being the same as the global object, I have integrated the alert function, I have integrated the document object and integrated the createElement function.
It looks like this (the HtmlDoc object is from the HTMLP library and has the DOM of the loaded webpage):
function TDocumentWrapper.createElement(const This : Variant; const Args : Array of Variant) : Variant;
var
TempElement : TElement;
TempObject : TSMObject;
begin
TempElement := HtmlDoc.createElement(VarToStr(Args[0]));
if (TempElement <> nil) then
begin
JSEnvironmentSender.NewObject(TempObject);
TempObject.DefineProperty('nodeName', TempElement.nodeName);
Result := TempObject.AsSMValue.AsJSVal;
end;
end;
However, alert only returns an empty string. If I call:
ShowMessage(TempObject.Properties['nodeName']);
I get testNode as expected. So I presume that TempObject.AsSMValue.AsJSVal is not the correct way of returning the object. Of course, I made sure that a simple alert("Hello world."); would work -- and it does.
How shall it be done?
Thanks.
Pages: 1