You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It should be possible to avoid the domUI queue and only use the dom queue.
Here are versions of the files that are needed to make this work:
text.js
"use strict";varcanReflect=require('can-reflect');varhelpers=require('./helpers');varqueues=require("can-queues");/** * @function can-view-live.text text * @parent can-view-live * @release 2.0.4 * * @signature `live.text(el, compute, [parentNode], [nodeList])` * * Replaces one element with some content while keeping [can-view-live.nodeLists nodeLists] data correct. */module.exports=function(el,compute){varhandlerName="";//!steal-remove-startif(process.env.NODE_ENV!=='production'){if(arguments.length>2){// TODO: removethrownewError("too many arguments");}handlerName="live.text update::"+canReflect.getName(compute);}//!steal-remove-end// TODO: we can remove this at some pointif(el.nodeType!==Node.TEXT_NODE){vartextNode;textNode=document.createTextNode("");el.parentNode.replaceChild(textNode,el);el=textNode;}functionsetValue(el,newVal){el.nodeValue=helpers.makeString(newVal);}varmeta={reasonLog: handlerName,element: el};varuseQueue=false;newhelpers.ListenUntilRemovedAndInitialize(compute,functionliveTextUpdateTextNode(newVal){if(useQueue){queues.domQueue.enqueue(setValue,null,[el,newVal],meta);}else{el.nodeValue=helpers.makeString(newVal);useQueue=true;}},el,"notify",// TODO: should this still be domUI?handlerName);};
attr.js
"use strict";varcanReflect=require('can-reflect');varattr=require("can-attribute-observable/behaviors");varhelpers=require('./helpers');varqueues=require("can-queues");/** * @function can-view-live.attr attr * @parent can-view-live * * @signature `live.attr(el, attributeName, observable)` * * Keep an attribute live to a [can-reflect]-ed observable. * * ```js * var div = document.createElement('div'); * var value = new SimpleObservable("foo bar"); * live.attr(div,"class", value); * ``` * * @param {HTMLElement} el The element whos attribute will be kept live. * @param {String} attributeName The attribute name. * @param {Object} observable An observable value. * * @body * * ## How it works * * This listens for the changes in the observable and uses those changes to * set the specified attribute. */module.exports=function(el,attributeName,compute){varhandlerName="";//!steal-remove-startif(process.env.NODE_ENV!=='production'){// register that the handler changes the parent elementhandlerName="live.attr update::"+canReflect.getName(compute);}//!steal-remove-endvaruseQueue=false;varmeta={reasonLog: handlerName,element: el};newhelpers.ListenUntilRemovedAndInitialize(compute,functionliveUpdateAttr(newVal){if(useQueue){queues.domQueue.enqueue(attr.set,attr,[el,attributeName,newVal],meta);}else{attr.set(el,attributeName,newVal);useQueue=true;}},el,"notify",handlerName);};
attrs.js
"use strict";// This provides live binding for stache attributes.varviewCallbacks=require('can-view-callbacks');vardomMutateNode=require('can-dom-mutate/node');varcanReflect=require('can-reflect');varhelpers=require('./helpers');varqueues=require("can-queues");functionupdateAttrs(el,newAttrs,oldAttrs,scope,options){varname;for(nameinnewAttrs){varnewValue=newAttrs[name],// `oldAttrs` was set on the last run of setAttrs in this context// (for this element and compute)oldValue=oldAttrs[name];// Only fire a callback// if the value of the attribute has changedif(newValue!==oldValue){// set on DOM attributes (dispatches an "attributes" event as well)domMutateNode.setAttribute.call(el,name,newValue);// get registered callback for attribute name and firevarcallback=viewCallbacks.attr(name);if(callback){callback(el,{attributeName: name,scope: scope,options: options});}}// remove key found in new attrs from old attrsdeleteoldAttrs[name];}// any attrs left at this point are not set on the element now,// so remove them.for(nameinoldAttrs){domMutateNode.removeAttribute.call(el,name);}}module.exports=function(el,compute,scope,options){varhandlerName="";if(!canReflect.isObservableLike(compute)){// Non-live case (`compute` was not a compute):// set all attributes on the element and don't// worry about setting up live binding since there// is not compute to bind on.varattrs=helpers.getAttributeParts(compute);for(varnameinattrs){domMutateNode.setAttribute.call(el,name,attrs[name]);}return;}//!steal-remove-startif(process.env.NODE_ENV!=='production'){handlerName="live.attrs update::"+canReflect.getName(compute);}//!steal-remove-end// last set of attributesvaroldAttrs={};varuseQueue=false;varmeta={reasonLog: handlerName,element: el};newhelpers.ListenUntilRemovedAndInitialize(compute,functioncanViewLive_updateAttributes(newVal){if(!useQueue){varnewAttrs=helpers.getAttributeParts(newVal);updateAttrs(el,newAttrs,oldAttrs,scope,options);oldAttrs=newAttrs;}else{queues.domQueue.enqueue(function(){varnewAttrs=helpers.getAttributeParts(newVal);updateAttrs(el,newAttrs,oldAttrs,scope,options);oldAttrs=newAttrs;},null,[],meta)}},el,"notify",handlerName);};
The text was updated successfully, but these errors were encountered:
It should be possible to avoid the
domUI
queue and only use thedom
queue.Here are versions of the files that are needed to make this work:
text.js
attr.js
attrs.js
The text was updated successfully, but these errors were encountered: