[Pas2js] missing definitions

Michael Van Canneyt michael at freepascal.org
Fri Aug 30 14:24:02 CEST 2019



Hello,

Added the missing fields/class, thank you !

Small tip:

When properties are read/write, you can declare them as fields of a class.

Only when a property is read-only you must declare it as a property:

property name : type read fname;

When you need to rename it, a field is also sufficient:

as_: string; external name 'as';

Michael.



On Fri, 30 Aug 2019, warleyalex via Pas2js wrote:

> // Test case
>
> (* Inject some Google fonts via: http://www.google.com/fonts/
>  The fonts are hosted at Google and you link them in the HTML header.
>  Then, you can use them freely in CSS
> *)
>
> procedure InjectFontLink(const url: string);
> var
>  el: TJSHTMLLinkElement;
> begin
>  el :=
> TJSHTMLLinkElement(TJSHTMLElement(window.document.createElement('link')));
>  el.rel := 'stylesheet';
>  el._type := 'text/css';
>  el.href := url;
> 
> TJSHTMLElement(window.document.getElementsByTagName('head')[0]).appendChild(el);
> end;
>
> InjectFontLink('https://fonts.googleapis.com/css?family=Rancho&effect=shadow-multiple');
>
> (...)
> then in you HTML
>
> <div class="font-effect-shadow-multiple">This is a font effect!<div>
> -----
> There is a minor type at the 'HTMLScriptElement' definition >> type_ :
> String; anyway.
>
> type
>  TJSHTMLScriptElement = class external name
> 'HTMLScriptElement'(TJSHTMLElement)
>  private
>    fsrc: string; external name 'src';
>    ftype: string; external name 'type';
>    fnoModule: boolean; external name 'noModule';
>    fasync: boolean; external name 'async';
>    fdefer: boolean; external name 'defer';
>    fcrossOrigin: string; external name 'crossOrigin';
>    ftext: string; external name 'text';
>    fcharset: string; external name 'charset';
>    fintegrity: string; external name 'integrity';
>    freferrerPolicy: string; external name 'referrerPolicy';
>  public
>    property src: string read fsrc write fsrc;
>    property _type: string read ftype write ftype;
>    property noModule: boolean read fnoModule write fnoModule;
>    property async: boolean read fasync write fasync;
>    property defer: boolean read fdefer write fdefer;
>    property crossOrigin: string read fcrossOrigin write fcrossOrigin;
>    property text: string read ftext write ftext;
>    property charset: string read fcharset write fcharset;
>    property integrity: string read fintegrity write fintegrity;
>    property referrerPolicy: string read freferrerPolicy write
> freferrerPolicy;
>  end;
>
>
>  {A DOMSettableTokenList object is equivalent to a DOMTokenList object
> without
>  an associated attribute.}
> type
>  TJSDOMSettableTokenList = class external name 'DOMSettableTokenList'
> (TJSDOMTokenList)
>  private
>    fvalue: TJSDOMString; external name 'value';
>  public
>    property value: TJSDOMString read fvalue; // readonly
>  end;
>
> type
>  TJSHTMLLinkElement = class external name 'HTMLLinkElement'(TJSHTMLElement)
>  private
>    fhref: string; external name 'href';
>    fcrossOrigin: string; external name 'crossOrigin';
>    frel: string; external name 'rel';
>    fas: string; external name 'as';
>    fmedia: string; external name 'media';
>    fintegrity: string; external name 'integrity';
>    fhreflang: string; external name 'hreflang';
>    ftype: string; external name 'type';
>    fimageSrcset: string; external name 'imageSrcset';
>    fimageSizes: string; external name 'imageSizes';
>    freferrerPolicy: string; external name 'referrerPolicy';
>    fdisabled: string; external name 'disabled';
>    frelList: TJSDOMTokenList; external name 'relList';
>    fsizes: TJSDOMSettableTokenList{TJSDOMTokenList}; external name 'sizes';
>    fcharset: string; external name 'charset'; // obsolete property
>    frev: string; external name 'rev'; // obsolete property
>    ftarget: string; external name 'target'; // obsolete property
>  public
>    property href: string read fhref write fhref;
>    property crossOrigin: string read fcrossOrigin write fcrossOrigin;
>    property rel: string read frel write frel;
>    property _as: string read fas write fas;
>    property media: string read fmedia write fmedia;
>    property integrity: string read fintegrity write fintegrity;
>    property hreflang: string read fhreflang write fhreflang;
>    property _type: string read ftype write ftype;
>    property imageSrcset: string read fimageSrcset write fimageSrcset;
>    property imageSizes: string read fimageSizes write fimageSizes;
>    property referrerPolicy: string read freferrerPolicy write
> freferrerPolicy;
>    property disabled: string read fdisabled write fdisabled;
>    property relList: TJSDOMTokenList read frelList;
>    property sizes: TJSDOMSettableTokenList{TJSDOMTokenList} read fsizes;
>    property charset: string read fcharset write fcharset; // obsolete
> property
>    property rev: string read frev write frev; // obsolete property
>    property target: string read ftarget write ftarget; // obsolete property
>  end; 
>
>
>
>
>
> --
> Sent from: http://pas2js.38893.n8.nabble.com/
> _______________________________________________
> Pas2js maillist  -  Pas2js at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js


More information about the Pas2js mailing list