javascript - Extending <object> in Dart -


the dart <object> element not support getter access <object>.contentdocument , thought extending object add functionality.

i took @ implementation of objectelement , need add these lines:

 @domname('htmlobjectelement.contentdocument')  @docseditable()  document contentdocument => _blink.blinkhtmlobjectelement.instance.contentdocument_getter_(this); 

however, have no idea how this. solution using @ time proxy redirects calls underlying jsobject honest, not dirty, impossible maintain.

/* updated explain root of evil */

when starting project working on, wanted display svgs, uploaded user, on website , let user manipulate these svgs inserting additional svgelements or removing others.

when downloading svgs string , displaying them by

container.append(new svgelement(svgcode))

i got strange display bugs such embeded images in svgs displaced or removed , other bugs masks.

the problem solved using <object> tag , set setting data attribute svg's url. svgs rendered correctly. being said, issue came up. wasn't able access , manipulate svgs dom because it's inside <object> tag , tag's document cannot accessed using contentdocument.

when taking account, there pretty 2 options left:

  1. i use <object> tag no display bugs not being able manipulate svgs or
  2. i create new svgelements fromt svg's source , append them dom let's me manipulate svgs having display bugs.

since having display bugs isn't solution can make use of first option, using <object> tag , working around javascript access object's contentdocument.

as can see, accessing contentdocument not security issue , not allowing make use of it, quick , dirty solution of problem.

when accessing contentdocument using jsobject, jsobject , not element. not have update code pretty everywhere, gets pretty ugly since have use jsobject callmethod(blabla).

class myobjectelement extends objectelement {   static bool _isregistered = false;    static register() {     if (!_isregistered) {       document.registerelement('my-object', myobjectelement,           extendstag: 'object');       _isregistered = true;     }   }    factory myobjectelement() {     var result = document.createelement('object', 'my-object');     return result;   }    myobjectelement.created() : super.created();    js.jsobject contentdocument {     // doesn't seem work custom element.     return new js.jsobject.frombrowserobject(this)['contentdocument'];   } } 

use like

myobjectelement.register(); var obj = new myobjectelement() ..data = "https://www.suntico.com/wp-content/uploads/demostamprotate01-e1400242575670.png"; document.body.append(obj);


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -