190 lines
6.7 KiB
JavaScript
190 lines
6.7 KiB
JavaScript
// Compiled by ClojureScript 1.9.946 {:static-fns true, :optimize-constants true}
|
|
goog.provide('reagent.dom');
|
|
goog.require('cljs.core');
|
|
goog.require('cljs.core.constants');
|
|
goog.require('reagent.impl.util');
|
|
goog.require('reagent.impl.template');
|
|
goog.require('reagent.impl.batching');
|
|
goog.require('reagent.ratom');
|
|
goog.require('reagent.debug');
|
|
goog.require('reagent.interop');
|
|
if(typeof reagent.dom.imported !== 'undefined'){
|
|
} else {
|
|
reagent.dom.imported = null;
|
|
}
|
|
reagent.dom.module = (function reagent$dom$module(){
|
|
if(!((reagent.dom.imported == null))){
|
|
return reagent.dom.imported;
|
|
} else {
|
|
if(typeof ReactDOM !== 'undefined'){
|
|
return reagent.dom.imported = ReactDOM;
|
|
} else {
|
|
if(typeof require !== 'undefined'){
|
|
var or__8782__auto__ = reagent.dom.imported = require("react-dom");
|
|
if(cljs.core.truth_(or__8782__auto__)){
|
|
return or__8782__auto__;
|
|
} else {
|
|
throw (new Error("require('react-dom') failed"));
|
|
}
|
|
} else {
|
|
throw (new Error("js/ReactDOM is missing"));
|
|
|
|
}
|
|
}
|
|
}
|
|
});
|
|
if(typeof reagent.dom.roots !== 'undefined'){
|
|
} else {
|
|
reagent.dom.roots = cljs.core.atom.cljs$core$IFn$_invoke$arity$1(cljs.core.PersistentArrayMap.EMPTY);
|
|
}
|
|
reagent.dom.unmount_comp = (function reagent$dom$unmount_comp(container){
|
|
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$3(reagent.dom.roots,cljs.core.dissoc,container);
|
|
|
|
return (reagent.dom.module()["unmountComponentAtNode"])(container);
|
|
});
|
|
reagent.dom.render_comp = (function reagent$dom$render_comp(comp,container,callback){
|
|
var _STAR_always_update_STAR_14882 = reagent.impl.util._STAR_always_update_STAR_;
|
|
reagent.impl.util._STAR_always_update_STAR_ = true;
|
|
|
|
try{return (reagent.dom.module()["render"])((comp.cljs$core$IFn$_invoke$arity$0 ? comp.cljs$core$IFn$_invoke$arity$0() : comp.call(null)),container,((function (_STAR_always_update_STAR_14882){
|
|
return (function (){
|
|
var _STAR_always_update_STAR_14883 = reagent.impl.util._STAR_always_update_STAR_;
|
|
reagent.impl.util._STAR_always_update_STAR_ = false;
|
|
|
|
try{cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$4(reagent.dom.roots,cljs.core.assoc,container,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [comp,container], null));
|
|
|
|
reagent.impl.batching.flush_after_render();
|
|
|
|
if(!((callback == null))){
|
|
return (callback.cljs$core$IFn$_invoke$arity$0 ? callback.cljs$core$IFn$_invoke$arity$0() : callback.call(null));
|
|
} else {
|
|
return null;
|
|
}
|
|
}finally {reagent.impl.util._STAR_always_update_STAR_ = _STAR_always_update_STAR_14883;
|
|
}});})(_STAR_always_update_STAR_14882))
|
|
);
|
|
}finally {reagent.impl.util._STAR_always_update_STAR_ = _STAR_always_update_STAR_14882;
|
|
}});
|
|
reagent.dom.re_render_component = (function reagent$dom$re_render_component(comp,container){
|
|
return reagent.dom.render_comp(comp,container,null);
|
|
});
|
|
/**
|
|
* Render a Reagent component into the DOM. The first argument may be
|
|
* either a vector (using Reagent's Hiccup syntax), or a React element. The second argument should be a DOM node.
|
|
*
|
|
* Optionally takes a callback that is called when the component is in place.
|
|
*
|
|
* Returns the mounted component instance.
|
|
*/
|
|
reagent.dom.render = (function reagent$dom$render(var_args){
|
|
var G__14885 = arguments.length;
|
|
switch (G__14885) {
|
|
case 2:
|
|
return reagent.dom.render.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
|
|
|
break;
|
|
case 3:
|
|
return reagent.dom.render.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
|
|
|
break;
|
|
default:
|
|
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
|
|
|
}
|
|
});
|
|
|
|
reagent.dom.render.cljs$core$IFn$_invoke$arity$2 = (function (comp,container){
|
|
return reagent.dom.render.cljs$core$IFn$_invoke$arity$3(comp,container,null);
|
|
});
|
|
|
|
reagent.dom.render.cljs$core$IFn$_invoke$arity$3 = (function (comp,container,callback){
|
|
reagent.ratom.flush_BANG_();
|
|
|
|
var f = (function (){
|
|
return reagent.impl.template.as_element(((cljs.core.fn_QMARK_(comp))?(comp.cljs$core$IFn$_invoke$arity$0 ? comp.cljs$core$IFn$_invoke$arity$0() : comp.call(null)):comp));
|
|
});
|
|
return reagent.dom.render_comp(f,container,callback);
|
|
});
|
|
|
|
reagent.dom.render.cljs$lang$maxFixedArity = 3;
|
|
|
|
reagent.dom.unmount_component_at_node = (function reagent$dom$unmount_component_at_node(container){
|
|
return reagent.dom.unmount_comp(container);
|
|
});
|
|
/**
|
|
* Returns the root DOM node of a mounted component.
|
|
*/
|
|
reagent.dom.dom_node = (function reagent$dom$dom_node(this$){
|
|
return (reagent.dom.module()["findDOMNode"])(this$);
|
|
});
|
|
reagent.impl.template.find_dom_node = reagent.dom.dom_node;
|
|
/**
|
|
* Force re-rendering of all mounted Reagent components. This is
|
|
* probably only useful in a development environment, when you want to
|
|
* update components in response to some dynamic changes to code.
|
|
*
|
|
* Note that force-update-all may not update root components. This
|
|
* happens if a component 'foo' is mounted with `(render [foo])` (since
|
|
* functions are passed by value, and not by reference, in
|
|
* ClojureScript). To get around this you'll have to introduce a layer
|
|
* of indirection, for example by using `(render [#'foo])` instead.
|
|
*/
|
|
reagent.dom.force_update_all = (function reagent$dom$force_update_all(){
|
|
reagent.ratom.flush_BANG_();
|
|
|
|
var seq__14887_14891 = cljs.core.seq(cljs.core.vals(cljs.core.deref(reagent.dom.roots)));
|
|
var chunk__14888_14892 = null;
|
|
var count__14889_14893 = (0);
|
|
var i__14890_14894 = (0);
|
|
while(true){
|
|
if((i__14890_14894 < count__14889_14893)){
|
|
var v_14895 = chunk__14888_14892.cljs$core$IIndexed$_nth$arity$2(null,i__14890_14894);
|
|
cljs.core.apply.cljs$core$IFn$_invoke$arity$2(reagent.dom.re_render_component,v_14895);
|
|
|
|
var G__14896 = seq__14887_14891;
|
|
var G__14897 = chunk__14888_14892;
|
|
var G__14898 = count__14889_14893;
|
|
var G__14899 = (i__14890_14894 + (1));
|
|
seq__14887_14891 = G__14896;
|
|
chunk__14888_14892 = G__14897;
|
|
count__14889_14893 = G__14898;
|
|
i__14890_14894 = G__14899;
|
|
continue;
|
|
} else {
|
|
var temp__5457__auto___14900 = cljs.core.seq(seq__14887_14891);
|
|
if(temp__5457__auto___14900){
|
|
var seq__14887_14901__$1 = temp__5457__auto___14900;
|
|
if(cljs.core.chunked_seq_QMARK_(seq__14887_14901__$1)){
|
|
var c__9713__auto___14902 = cljs.core.chunk_first(seq__14887_14901__$1);
|
|
var G__14903 = cljs.core.chunk_rest(seq__14887_14901__$1);
|
|
var G__14904 = c__9713__auto___14902;
|
|
var G__14905 = cljs.core.count(c__9713__auto___14902);
|
|
var G__14906 = (0);
|
|
seq__14887_14891 = G__14903;
|
|
chunk__14888_14892 = G__14904;
|
|
count__14889_14893 = G__14905;
|
|
i__14890_14894 = G__14906;
|
|
continue;
|
|
} else {
|
|
var v_14907 = cljs.core.first(seq__14887_14901__$1);
|
|
cljs.core.apply.cljs$core$IFn$_invoke$arity$2(reagent.dom.re_render_component,v_14907);
|
|
|
|
var G__14908 = cljs.core.next(seq__14887_14901__$1);
|
|
var G__14909 = null;
|
|
var G__14910 = (0);
|
|
var G__14911 = (0);
|
|
seq__14887_14891 = G__14908;
|
|
chunk__14888_14892 = G__14909;
|
|
count__14889_14893 = G__14910;
|
|
i__14890_14894 = G__14911;
|
|
continue;
|
|
}
|
|
} else {
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
return "Updated";
|
|
});
|