Hi,
I'm submitting a ...
Within hyperapp sometimes I need to make some preparations, to ensure everything is going fine with DOM/events/data. For example:
- generate
<video> element, append some sources, and check which one browser wants to load;
- create
<img> element and check if image is accessible and what size they have;
- insert
svg fragment into already loaded though <object> tag svg dom.
It is really useful to have function, which renders h('video', ...) into new Element, which can be inserted into existing DOM or just loaded (like images or videos), because as of now my preparations looks like
const el = document.createElement('video');
el.addEventListener('loadeddata', this.onVideoLoad.bind(this), false);
el.addEventListener('abort', this.onVideoAbort.bind(this), false);
el.addEventListener('waiting', this.onVideoWaiting.bind(this), false);
el.addEventListener('loadedmetadata', this.onVideoMeta.bind (this), false);
el.setAttribute('preload', 'metadata');
el.setAttribute('muted', 'true');
el.setAttribute('playsinline', 'true');
this.config.sources.forEach(source => {
var srcEl = document.createElement('source');
srcEl.src = patchLocalVideo(source.url);
srcEl.type = source.type;
el.appendChild(srcEl);
});
I can implement it myself and make a pull request if you're interested in this.
Hi,
I'm submitting a ...
Within hyperapp sometimes I need to make some preparations, to ensure everything is going fine with DOM/events/data. For example:
<video>element, append some sources, and check which one browser wants to load;<img>element and check if image is accessible and what size they have;svgfragment into already loaded though<object>tagsvgdom.It is really useful to have function, which renders
h('video', ...)into new Element, which can be inserted into existing DOM or just loaded (like images or videos), because as of now my preparations looks likeI can implement it myself and make a pull request if you're interested in this.