123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111(* Js_of_ocaml library
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2015 Stéphane Legrand
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)open!ImportclasstypemutationObserverInit=objectmethodchildList:boolJs.writeonly_propmethodattributes:boolJs.writeonly_propmethodcharacterData:boolJs.writeonly_propmethodsubtree:boolJs.writeonly_propmethodattributeOldValue:boolJs.writeonly_propmethodcharacterDataOldValue:boolJs.writeonly_propmethodattributeFilter:Js.js_stringJs.tJs.js_arrayJs.tJs.writeonly_propendclasstypemutationRecord=objectmethod_type:Js.js_stringJs.tJs.readonly_propmethodtarget:Dom.nodeJs.tJs.readonly_propmethodaddedNodes:Dom.nodeDom.nodeListJs.tJs.readonly_propmethodremovedNodes:Dom.nodeDom.nodeListJs.tJs.readonly_propmethodpreviousSibling:Dom.nodeJs.tJs.optJs.readonly_propmethodnextSibling:Dom.nodeJs.tJs.optJs.readonly_propmethodattributeName:Js.js_stringJs.tJs.optJs.readonly_propmethodattributeNamespace:Js.js_stringJs.tJs.optJs.readonly_propmethodoldValue:Js.js_stringJs.tJs.optJs.readonly_propendclasstypemutationObserver=objectmethodobserve:#Dom.nodeJs.t->mutationObserverInitJs.t->unitJs.methmethoddisconnect:unitJs.methmethodtakeRecords:mutationRecordJs.tJs.js_arrayJs.tJs.methendletempty_mutation_observer_init():mutationObserverInitJs.t=Js.Unsafe.obj[||]letmutationObserver=Js.Unsafe.global##._MutationObserverletis_supported()=Js.Optdef.testmutationObserverletmutationObserver:((mutationRecordJs.tJs.js_arrayJs.t->mutationObserverJs.t->unit)Js.callback->mutationObserverJs.t)Js.constr=mutationObserverletobserve~(node:#Dom.nodeJs.t)~(f:mutationRecordJs.tJs.js_arrayJs.t->mutationObserverJs.t->unit)?(child_list:booloption)?(attributes:booloption)?(character_data:booloption)?(subtree:booloption)?(attribute_old_value:booloption)?(character_data_old_value:booloption)?(attribute_filter:Js.js_stringJs.tlistoption)():mutationObserverJs.t=letopt_iterxf=matchxwith|None->()|Somex->fxinletobs=new%jsmutationObserver(Js.wrap_callbackf)inletcfg=empty_mutation_observer_init()inlet()=opt_iterchild_list(funv->cfg##.childList:=v)inlet()=opt_iterattributes(funv->cfg##.attributes:=v)inlet()=opt_itercharacter_data(funv->cfg##.characterData:=v)inlet()=opt_itersubtree(funv->cfg##.subtree:=v)inlet()=opt_iterattribute_old_value(funv->cfg##.attributeOldValue:=v)inlet()=opt_itercharacter_data_old_value(funv->cfg##.characterDataOldValue:=v)inlet()=opt_iterattribute_filter(funl->cfg##.attributeFilter:=Js.array(Array.of_listl))inlet()=obs##observenodecfginobs