{"version":3,"file":"ractive.min.js","sources":["../src/view/RepeatedFragment.js","../src/view/items/Section.js","../src/view/items/element/specials/Select.js","../src/view/items/element/specials/Textarea.js","../src/view/items/Text.js","../src/view/items/element/transitions/prefix.js","../src/config/visibility.js","../src/view/items/element/transitions/hyphenate.js","../src/view/items/element/transitions/createTransitions.js","../src/view/items/element/Transition.js","../src/view/items/triple/insertHtml.js","../src/view/items/Triple.js","../src/view/items/createItem.js","../src/view/Fragment.js","../src/events/HookQueue.js","../src/Ractive/initialise.js","../src/Ractive/render.js","../src/Ractive/prototype/reset.js","../src/Ractive/prototype/resetPartial.js","../src/Ractive/prototype/reverse.js","../src/Ractive/prototype/shift.js","../src/Ractive/prototype/sort.js","../src/Ractive/prototype/splice.js","../src/Ractive/prototype/unrender.js","../src/Ractive/prototype/unshift.js","../src/Ractive/prototype.js","../src/extend/_extend.js","../src/Ractive.js","../src/view/items/element/binding/CheckboxNameBinding.js","../src/view/items/element/binding/ContentEditableBinding.js","../src/view/items/element/binding/GenericBinding.js","../src/view/items/element/binding/FileBinding.js","../src/view/items/element/binding/MultipleSelectBinding.js","../src/view/items/element/binding/NumericBinding.js","../src/view/items/element/binding/RadioBinding.js","../src/view/items/element/binding/RadioNameBinding.js","../src/view/items/element/binding/SingleSelectBinding.js","../src/view/items/Element.js","../src/view/items/element/specials/Form.js","../src/view/items/element/ElementEvents.js","../src/view/items/component/RactiveEvent.js","../src/view/items/shared/EventDirective.js","../src/view/items/shared/Mustache.js","../src/view/items/Interpolator.js","../src/view/items/element/specials/Input.js","../src/utils/parseJSON.js","../src/view/items/component/Mapping.js","../src/view/items/element/specials/Option.js","../src/view/items/Partial.js","../src/Ractive/config/runtime-parser.js","../src/Ractive/config/custom/template.js","../src/Ractive/config/registries.js","../src/Ractive/config/config.js","../src/view/items/shared/Item.js","../src/model/ComputationChild.js","../src/model/Computation.js","../src/view/resolvers/ExpressionProxy.js","../src/view/resolvers/ReferenceExpressionProxy.js","../src/view/items/Alias.js","../src/view/helpers/specialAttrs.js","../src/utils/hyphenateCamel.js","../src/view/items/element/attribute/getUpdateDelegate.js","../src/view/items/element/attribute/propertyNames.js","../src/view/items/element/ConditionalAttribute.js","../src/view/items/element/Attribute.js","../src/view/items/element/BindingFlag.js","../src/model/specials/RactiveModel.js","../src/model/RootModel.js","../src/Ractive/construct.js","../src/Ractive/prototype/teardown.js","../src/view/items/Component.js","../src/view/items/element/Decorator.js","../src/view/items/Doctype.js","../src/view/items/element/binding/Binding.js","../src/view/items/element/binding/CheckboxBinding.js","../src/view/items/element/binding/getBindingGroup.js","../src/model/Model.js","../src/model/specials/SharedModel.js","../src/view/resolvers/resolveReference.js","../src/shared/getRactiveContext.js","../src/shared/set.js","../src/Ractive/prototype/shared/add.js","../src/Ractive/prototype/animate.js","../src/events/fireEvent.js","../src/events/Hook.js","../src/Ractive/prototype/attachChild.js","../src/Ractive/prototype/detach.js","../src/Ractive/prototype/detachChild.js","../src/Ractive/prototype/shared/makeArrayMethod.js","../src/Ractive/prototype/update.js","../src/config/types.js","../src/shared/Context.js","../src/Ractive/static/getContext.js","../src/utils/dom.js","../src/config/namespaces.js","../src/Ractive/prototype/insert.js","../src/Ractive/prototype/observe/Observer.js","../src/Ractive/prototype/observe/Pattern.js","../src/Ractive/prototype/observe/Array.js","../src/Ractive/prototype/observeOnce.js","../src/Ractive/prototype/shared/trim.js","../src/Ractive/prototype/shared/notEmptyString.js","../src/Ractive/prototype/pop.js","../src/Ractive/prototype/push.js","../src/global/css.js","../src/Ractive/config/custom/adapt.js","../src/utils/cleanCss.js","../src/Ractive/config/custom/css/transform.js","../src/Ractive/config/custom/css/css.js","../src/Ractive/config/custom/data.js","../src/config/template.js","../src/parse/utils/createFunction.js","../src/shared/getFunction.js","../src/parse/Parser.js","../src/parse/converters/mustache/readDelimiterChange.js","../src/parse/converters/expressions/readTypeof.js","../src/parse/converters/expressions/primary/literal/readRegexpLiteral.js","../src/utils/escapeRegExp.js","../src/parse/converters/utils/getLowestIndex.js","../src/utils/html.js","../src/parse/converters/expressions/shared/errors.js","../src/parse/converters/expressions/primary/literal/readNumberLiteral.js","../src/parse/converters/expressions/primary/literal/stringLiteral/makeQuotedStringMatcher.js","../src/parse/converters/expressions/primary/literal/readStringLiteral.js","../src/parse/converters/expressions/primary/literal/readTemplateStringLiteral.js","../src/parse/converters/expressions/shared/patterns.js","../src/parse/converters/expressions/shared/readKey.js","../src/parse/converters/expressions/primary/literal/readObjectLiteral.js","../src/parse/converters/expressions/primary/literal/readArrayLiteral.js","../src/parse/converters/expressions/primary/readReference.js","../src/parse/converters/expressions/readPrimary.js","../src/parse/converters/expressions/readMemberOrInvocation.js","../src/parse/converters/expressions/readLogicalOr.js","../src/parse/converters/element/readAttribute.js","../src/parse/converters/readMustache.js","../src/parse/converters/mustache/readAliases.js","../src/parse/converters/mustache/section/readElse.js","../src/parse/converters/mustache/section/readElseIf.js","../src/parse/converters/mustache/handlebarsBlockCodes.js","../src/parse/converters/mustache/readSection.js","../src/parse/converters/readHtmlComment.js","../src/parse/utils/stripStandalones.js","../src/parse/utils/trimWhitespace.js","../src/parse/utils/cleanup.js","../src/parse/converters/element/readClosingTag.js","../src/parse/converters/readElement.js","../src/parse/converters/readPartialDefinitionSection.js","../src/Ractive/shared.js","../src/parse/_parse.js","../src/view/items/shared/progressiveText.js","../src/view/items/partial/getPartialTemplate.js","../src/view/items/component/getComponentConstructor.js","../src/view/helpers/processItems.js","../src/Ractive/prototype/render.js","../src/Ractive/prototype/resetTemplate.js","../src/Ractive/prototype/set.js","../src/Ractive/prototype/subtract.js","../src/Ractive/prototype/toggle.js","../src/Ractive/prototype/toCSS.js","../src/Ractive/prototype/toHTML.js","../src/Ractive/prototype/toText.js","../src/Ractive/prototype/transition.js","../src/Ractive/prototype/unlink.js","../src/Ractive/prototype/updateModel.js","../src/Ractive/static/isInstance.js","../src/Ractive/static/keypaths.js","../src/Ractive/static/findPlugin.js","../src/polyfills/performance.now.js","../src/polyfills/array.find.js","../src/polyfills/node.contains.js","../src/polyfills/Object.assign.js","../src/polyfills/Promise.js","../src/polyfills/requestAnimationFrame.js","../src/Ractive/config/defaults.js","../src/utils/log.js","../src/Ractive/static/easing.js","../src/utils/is.js","../src/config/environment.js","../src/utils/noop.js","../src/config/errors.js","../src/Ractive/static/interpolators.js","../src/global/TransitionManager.js","../src/global/runloop.js","../src/global/capture.js","../src/shared/keypaths.js","../src/model/specials/KeyModel.js","../src/model/specials/KeypathModel.js","../src/utils/bind.js","../src/model/ModelBase.js","../src/model/LinkModel.js","../src/shared/Ticker.js","../src/model/helpers/getPrefixer.js","../src/parse/utils/flattenExpression.js","../src/parse/utils/refineExpression.js","../src/parse/converters/mustache/readTriple.js","../src/parse/converters/mustache/readUnescaped.js","../src/parse/converters/mustache/readPartial.js","../src/parse/converters/mustache/readMustacheComment.js","../src/parse/converters/mustache/readInterpolator.js","../src/parse/converters/mustache/section/readClosing.js","../src/parse/converters/readText.js","../src/parse/converters/readTemplate.js","../src/parse/utils/insertExpressions.js","../src/Ractive/config/wrapPrototypeMethod.js","../src/Ractive/config/deprecate.js","../src/view/resolvers/resolve.js","../src/Ractive/helpers/getComputationSignature.js","../src/utils/object.js","../src/Ractive/helpers/subscribe.js","../src/view/items/shared/directiveArgs.js","../src/view/items/element/binding/handleDomEvent.js","../src/utils/getSelectedOptions.js","../src/view/items/element/binding/selectBinding.js","../src/shared/registry.js","../src/shared/interpolate.js","../src/utils/array.js","../src/shared/methodCallers.js","../src/shared/rebind.js","../src/Ractive/prototype/add.js","../src/events/eventStack.js","../src/shared/anchors.js","../src/Ractive/prototype/find.js","../src/Ractive/prototype/findAll.js","../src/Ractive/prototype/findAllComponents.js","../src/Ractive/prototype/findComponent.js","../src/Ractive/prototype/findContainer.js","../src/Ractive/prototype/findParent.js","../src/shared/getNewIndices.js","../src/view/items/shared/findElement.js","../src/Ractive/prototype/fire.js","../src/Ractive/prototype/get.js","../src/Ractive/prototype/getContext.js","../src/Ractive/prototype/link.js","../src/Ractive/prototype/observe.js","../src/Ractive/prototype/off.js","../src/Ractive/prototype/on.js","../src/Ractive/prototype/once.js","../src/Ractive/prototype/readLink.js","../src/utils/id.js","../src/parse/converters/expressions/primary/literal/readBooleanLiteral.js","../src/parse/converters/expressions/primary/literal/objectLiteral/keyValuePair.js","../src/parse/converters/expressions/primary/literal/objectLiteral/keyValuePairs.js","../src/parse/converters/expressions/primary/readLiteral.js","../src/parse/converters/expressions/primary/readBracketedExpression.js","../src/parse/converters/expressions/shared/readRefinement.js","../src/parse/converters/expressions/readConditional.js","../src/parse/converters/readExpression.js","../src/parse/converters/expressions/shared/readExpressionList.js","../src/parse/converters/readExpressionOrReference.js"],"sourcesContent":["import Fragment from './Fragment';\nimport { createDocumentFragment } from '../utils/dom';\nimport { isObject } from '../utils/is';\nimport { findMap } from '../utils/array';\nimport { toEscapedString, toString, destroyed, shuffled, unbind, unrender, unrenderAndDestroy, update } from '../shared/methodCallers';\nimport findElement from './items/shared/findElement';\n\nexport default class RepeatedFragment {\n\tconstructor ( options ) {\n\t\tthis.parent = options.owner.parentFragment;\n\n\t\t// bit of a hack, so reference resolution works without another\n\t\t// layer of indirection\n\t\tthis.parentFragment = this;\n\t\tthis.owner = options.owner;\n\t\tthis.ractive = this.parent.ractive;\n\t\tthis.delegate = this.ractive.delegate !== false && ( this.parent.delegate || findDelegate( findElement( options.owner ) ) );\n\t\t// delegation disabled by directive\n\t\tif ( this.delegate && this.delegate.delegate === false ) this.delegate = false;\n\t\t// let the element know it's a delegate handler\n\t\tif ( this.delegate ) this.delegate.delegate = this.delegate;\n\n\t\t// encapsulated styles should be inherited until they get applied by an element\n\t\tthis.cssIds = 'cssIds' in options ? options.cssIds : ( this.parent ? this.parent.cssIds : null );\n\n\t\tthis.context = null;\n\t\tthis.rendered = false;\n\t\tthis.iterations = [];\n\n\t\tthis.template = options.template;\n\n\t\tthis.indexRef = options.indexRef;\n\t\tthis.keyRef = options.keyRef;\n\n\t\tthis.pendingNewIndices = null;\n\t\tthis.previousIterations = null;\n\n\t\t// track array versus object so updates of type rest\n\t\tthis.isArray = false;\n\t}\n\n\tbind ( context ) {\n\t\tthis.context = context;\n\t\tconst value = context.get();\n\n\t\t// {{#each array}}...\n\t\tif ( this.isArray = Array.isArray( value ) ) {\n\t\t\t// we can't use map, because of sparse arrays\n\t\t\tthis.iterations = [];\n\t\t\tconst max = value.length;\n\t\t\tfor ( let i = 0; i < max; i += 1 ) {\n\t\t\t\tthis.iterations[i] = this.createIteration( i, i );\n\t\t\t}\n\t\t}\n\n\t\t// {{#each object}}...\n\t\telse if ( isObject( value ) ) {\n\t\t\tthis.isArray = false;\n\n\t\t\t// TODO this is a dreadful hack. There must be a neater way\n\t\t\tif ( this.indexRef ) {\n\t\t\t\tconst refs = this.indexRef.split( ',' );\n\t\t\t\tthis.keyRef = refs[0];\n\t\t\t\tthis.indexRef = refs[1];\n\t\t\t}\n\n\t\t\tthis.iterations = Object.keys( value ).map( ( key, index ) => {\n\t\t\t\treturn this.createIteration( key, index );\n\t\t\t});\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tbubble ( index ) {\n\t\tif ( !this.bubbled ) this.bubbled = [];\n\t\tthis.bubbled.push( index );\n\n\t\tthis.owner.bubble();\n\t}\n\n\tcreateIteration ( key, index ) {\n\t\tconst fragment = new Fragment({\n\t\t\towner: this,\n\t\t\ttemplate: this.template\n\t\t});\n\n\t\tfragment.key = key;\n\t\tfragment.index = index;\n\t\tfragment.isIteration = true;\n\t\tfragment.delegate = this.delegate;\n\n\t\tconst model = this.context.joinKey( key );\n\n\t\t// set up an iteration alias if there is one\n\t\tif ( this.owner.template.z ) {\n\t\t\tfragment.aliases = {};\n\t\t\tfragment.aliases[ this.owner.template.z[0].n ] = model;\n\t\t}\n\n\t\treturn fragment.bind( model );\n\t}\n\n\tdestroyed () {\n\t\tthis.iterations.forEach( destroyed );\n\t}\n\n\tdetach () {\n\t\tconst docFrag = createDocumentFragment();\n\t\tthis.iterations.forEach( fragment => docFrag.appendChild( fragment.detach() ) );\n\t\treturn docFrag;\n\t}\n\n\tfind ( selector, options ) {\n\t\treturn findMap( this.iterations, i => i.find( selector, options ) );\n\t}\n\n\tfindAll ( selector, options ) {\n\t\treturn this.iterations.forEach( i => i.findAll( selector, options ) );\n\t}\n\n\tfindComponent ( name, options ) {\n\t\treturn findMap( this.iterations, i => i.findComponent( name, options ) );\n\t}\n\n\tfindAllComponents ( name, options ) {\n\t\treturn this.iterations.forEach( i => i.findAllComponents( name, options ) );\n\t}\n\n\tfindNextNode ( iteration ) {\n\t\tif ( iteration.index < this.iterations.length - 1 ) {\n\t\t\tfor ( let i = iteration.index + 1; i < this.iterations.length; i++ ) {\n\t\t\t\tconst node = this.iterations[ i ].firstNode( true );\n\t\t\t\tif ( node ) return node;\n\t\t\t}\n\t\t}\n\n\t\treturn this.owner.findNextNode();\n\t}\n\n\tfirstNode ( skipParent ) {\n\t\treturn this.iterations[0] ? this.iterations[0].firstNode( skipParent ) : null;\n\t}\n\n\trebind ( next ) {\n\t\tthis.context = next;\n\t\tthis.iterations.forEach( fragment => {\n\t\t\tconst model = next ? next.joinKey( fragment.key ) : undefined;\n\t\t\tfragment.context = model;\n\t\t\tif ( this.owner.template.z ) {\n\t\t\t\tfragment.aliases = {};\n\t\t\t\tfragment.aliases[ this.owner.template.z[0].n ] = model;\n\t\t\t}\n\t\t});\n\t}\n\n\trender ( target, occupants ) {\n\t\t// TODO use docFrag.cloneNode...\n\n\t\tconst xs = this.iterations;\n\t\tif ( xs ) {\n\t\t\tconst len = xs.length;\n\t\t\tfor ( let i = 0; i < len; i++ ) {\n\t\t\t\txs[i].render( target, occupants );\n\t\t\t}\n\t\t}\n\n\t\tthis.rendered = true;\n\t}\n\n\tshuffle ( newIndices ) {\n\t\tif ( !this.pendingNewIndices ) this.previousIterations = this.iterations.slice();\n\n\t\tif ( !this.pendingNewIndices ) this.pendingNewIndices = [];\n\n\t\tthis.pendingNewIndices.push( newIndices );\n\n\t\tconst iterations = [];\n\n\t\tnewIndices.forEach( ( newIndex, oldIndex ) => {\n\t\t\tif ( newIndex === -1 ) return;\n\n\t\t\tconst fragment = this.iterations[ oldIndex ];\n\t\t\titerations[ newIndex ] = fragment;\n\n\t\t\tif ( newIndex !== oldIndex && fragment ) fragment.dirty = true;\n\t\t});\n\n\t\tthis.iterations = iterations;\n\n\t\tthis.bubble();\n\t}\n\n\tshuffled () {\n\t\tthis.iterations.forEach( shuffled );\n\t}\n\n\ttoString ( escape ) {\n\t\treturn this.iterations ?\n\t\t\tthis.iterations.map( escape ? toEscapedString : toString ).join( '' ) :\n\t\t\t'';\n\t}\n\n\tunbind () {\n\t\tthis.iterations.forEach( unbind );\n\t\treturn this;\n\t}\n\n\tunrender ( shouldDestroy ) {\n\t\tthis.iterations.forEach( shouldDestroy ? unrenderAndDestroy : unrender );\n\t\tif ( this.pendingNewIndices && this.previousIterations ) {\n\t\t\tthis.previousIterations.forEach( fragment => {\n\t\t\t\tif ( fragment.rendered ) shouldDestroy ? unrenderAndDestroy( fragment ) : unrender( fragment );\n\t\t\t});\n\t\t}\n\t\tthis.rendered = false;\n\t}\n\n\t// TODO smart update\n\tupdate () {\n\t\t// skip dirty check, since this is basically just a facade\n\n\t\tif ( this.pendingNewIndices ) {\n\t\t\tthis.bubbled.length = 0;\n\t\t\tthis.updatePostShuffle();\n\t\t\treturn;\n\t\t}\n\n\t\tif ( this.updating ) return;\n\t\tthis.updating = true;\n\n\t\tconst value = this.context.get();\n\t\tconst wasArray = this.isArray;\n\n\t\tlet toRemove;\n\t\tlet oldKeys;\n\t\tlet reset = true;\n\t\tlet i;\n\n\t\tif ( this.isArray = Array.isArray( value ) ) {\n\t\t\tif ( wasArray ) {\n\t\t\t\treset = false;\n\t\t\t\tif ( this.iterations.length > value.length ) {\n\t\t\t\t\ttoRemove = this.iterations.splice( value.length );\n\t\t\t\t}\n\t\t\t}\n\t\t} else if ( isObject( value ) && !wasArray ) {\n\t\t\treset = false;\n\t\t\ttoRemove = [];\n\t\t\toldKeys = {};\n\t\t\ti = this.iterations.length;\n\n\t\t\twhile ( i-- ) {\n\t\t\t\tconst fragment = this.iterations[i];\n\t\t\t\tif ( fragment.key in value ) {\n\t\t\t\t\toldKeys[ fragment.key ] = true;\n\t\t\t\t} else {\n\t\t\t\t\tthis.iterations.splice( i, 1 );\n\t\t\t\t\ttoRemove.push( fragment );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( reset ) {\n\t\t\ttoRemove = this.iterations;\n\t\t\tthis.iterations = [];\n\t\t}\n\n\t\tif ( toRemove ) {\n\t\t\ttoRemove.forEach( fragment => {\n\t\t\t\tfragment.unbind();\n\t\t\t\tfragment.unrender( true );\n\t\t\t});\n\t\t}\n\n\t\t// update the remaining ones\n\t\tif ( !reset && this.isArray && this.bubbled && this.bubbled.length ) {\n\t\t\tconst bubbled = this.bubbled;\n\t\t\tthis.bubbled = [];\n\t\t\tbubbled.forEach( i => this.iterations[i] && this.iterations[i].update() );\n\t\t} else {\n\t\t\tthis.iterations.forEach( update );\n\t\t}\n\n\t\t// add new iterations\n\t\tconst newLength = Array.isArray( value ) ?\n\t\t\tvalue.length :\n\t\t\tisObject( value ) ?\n\t\t\t\tObject.keys( value ).length :\n\t\t\t\t0;\n\n\t\tlet docFrag;\n\t\tlet fragment;\n\n\t\tif ( newLength > this.iterations.length ) {\n\t\t\tdocFrag = this.rendered ? createDocumentFragment() : null;\n\t\t\ti = this.iterations.length;\n\n\t\t\tif ( Array.isArray( value ) ) {\n\t\t\t\twhile ( i < value.length ) {\n\t\t\t\t\tfragment = this.createIteration( i, i );\n\n\t\t\t\t\tthis.iterations.push( fragment );\n\t\t\t\t\tif ( this.rendered ) fragment.render( docFrag );\n\n\t\t\t\t\ti += 1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\telse if ( isObject( value ) ) {\n\t\t\t\t// TODO this is a dreadful hack. There must be a neater way\n\t\t\t\tif ( this.indexRef && !this.keyRef ) {\n\t\t\t\t\tconst refs = this.indexRef.split( ',' );\n\t\t\t\t\tthis.keyRef = refs[0];\n\t\t\t\t\tthis.indexRef = refs[1];\n\t\t\t\t}\n\n\t\t\t\tObject.keys( value ).forEach( key => {\n\t\t\t\t\tif ( !oldKeys || !( key in oldKeys ) ) {\n\t\t\t\t\t\tfragment = this.createIteration( key, i );\n\n\t\t\t\t\t\tthis.iterations.push( fragment );\n\t\t\t\t\t\tif ( this.rendered ) fragment.render( docFrag );\n\n\t\t\t\t\t\ti += 1;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif ( this.rendered ) {\n\t\t\t\tconst parentNode = this.parent.findParentNode();\n\t\t\t\tconst anchor = this.parent.findNextNode( this.owner );\n\n\t\t\t\tparentNode.insertBefore( docFrag, anchor );\n\t\t\t}\n\t\t}\n\n\t\tthis.updating = false;\n\t}\n\n\tupdatePostShuffle () {\n\t\tconst newIndices = this.pendingNewIndices[ 0 ];\n\n\t\t// map first shuffle through\n\t\tthis.pendingNewIndices.slice( 1 ).forEach( indices => {\n\t\t\tnewIndices.forEach( ( newIndex, oldIndex ) => {\n\t\t\t\tnewIndices[ oldIndex ] = indices[ newIndex ];\n\t\t\t});\n\t\t});\n\n\t\t// This algorithm (for detaching incorrectly-ordered fragments from the DOM and\n\t\t// storing them in a document fragment for later reinsertion) seems a bit hokey,\n\t\t// but it seems to work for now\n\t\tconst len = this.context.get().length;\n\t\tconst oldLen = this.previousIterations.length;\n\t\tconst removed = {};\n\t\tlet i;\n\n\t\tnewIndices.forEach( ( newIndex, oldIndex ) => {\n\t\t\tconst fragment = this.previousIterations[ oldIndex ];\n\t\t\tthis.previousIterations[ oldIndex ] = null;\n\n\t\t\tif ( newIndex === -1 ) {\n\t\t\t\tremoved[ oldIndex ] = fragment;\n\t\t\t} else if ( fragment.index !== newIndex ) {\n\t\t\t\tconst model = this.context.joinKey( newIndex );\n\t\t\t\tfragment.index = fragment.key = newIndex;\n\t\t\t\tfragment.context = model;\n\t\t\t\tif ( this.owner.template.z ) {\n\t\t\t\t\tfragment.aliases = {};\n\t\t\t\t\tfragment.aliases[ this.owner.template.z[0].n ] = model;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// if the array was spliced outside of ractive, sometimes there are leftover fragments not in the newIndices\n\t\tthis.previousIterations.forEach( ( frag, i ) => {\n\t\t\tif ( frag ) removed[ i ] = frag;\n\t\t});\n\n\t\t// create new/move existing iterations\n\t\tconst docFrag = this.rendered ? createDocumentFragment() : null;\n\t\tconst parentNode = this.rendered ? this.parent.findParentNode() : null;\n\n\t\tconst contiguous = 'startIndex' in newIndices;\n\t\ti = contiguous ? newIndices.startIndex : 0;\n\n\t\tfor ( i; i < len; i++ ) {\n\t\t\tconst frag = this.iterations[i];\n\n\t\t\tif ( frag && contiguous ) {\n\t\t\t\t// attach any built-up iterations\n\t\t\t\tif ( this.rendered ) {\n\t\t\t\t\tif ( removed[i] ) docFrag.appendChild( removed[i].detach() );\n\t\t\t\t\tif ( docFrag.childNodes.length ) parentNode.insertBefore( docFrag, frag.firstNode() );\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif ( !frag ) this.iterations[i] = this.createIteration( i, i );\n\n\t\t\tif ( this.rendered ) {\n\t\t\t\tif ( removed[i] ) docFrag.appendChild( removed[i].detach() );\n\n\t\t\t\tif ( frag ) docFrag.appendChild( frag.detach() );\n\t\t\t\telse {\n\t\t\t\t\tthis.iterations[i].render( docFrag );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// append any leftovers\n\t\tif ( this.rendered ) {\n\t\t\tfor ( i = len; i < oldLen; i++ ) {\n\t\t\t\tif ( removed[i] ) docFrag.appendChild( removed[i].detach() );\n\t\t\t}\n\n\t\t\tif ( docFrag.childNodes.length ) {\n\t\t\t\tparentNode.insertBefore( docFrag, this.owner.findNextNode() );\n\t\t\t}\n\t\t}\n\n\t\t// trigger removal on old nodes\n\t\tObject.keys( removed ).forEach( k => removed[k].unbind().unrender( true ) );\n\n\t\tthis.iterations.forEach( update );\n\n\t\tthis.pendingNewIndices = null;\n\n\t\tthis.shuffled();\n\t}\n}\n\n// find the topmost delegate\nfunction findDelegate ( start ) {\n\tlet el = start;\n\tlet delegate = start;\n\n\twhile ( el ) {\n\t\tif ( el.delegate ) delegate = el;\n\t\tel = el.parent;\n\t}\n\n\treturn delegate;\n}\n","import { createDocumentFragment } from '../../utils/dom';\nimport { SECTION_EACH, SECTION_IF, SECTION_IF_WITH, SECTION_UNLESS, SECTION_WITH } from '../../config/types';\nimport { isObject } from '../../utils/is';\nimport Fragment from '../Fragment';\nimport RepeatedFragment from '../RepeatedFragment';\nimport { MustacheContainer } from './shared/Mustache';\nimport { keep } from '../../shared/set';\nimport runloop from '../../global/runloop';\n\nfunction isEmpty ( value ) {\n\treturn !value ||\n\t ( Array.isArray( value ) && value.length === 0 ) ||\n\t\t ( isObject( value ) && Object.keys( value ).length === 0 );\n}\n\nfunction getType ( value, hasIndexRef ) {\n\tif ( hasIndexRef || Array.isArray( value ) ) return SECTION_EACH;\n\tif ( isObject( value ) || typeof value === 'function' ) return SECTION_IF_WITH;\n\tif ( value === undefined ) return null;\n\treturn SECTION_IF;\n}\n\nexport default class Section extends MustacheContainer {\n\tconstructor ( options ) {\n\t\tsuper( options );\n\n\t\tthis.sectionType = options.template.n || null;\n\t\tthis.templateSectionType = this.sectionType;\n\t\tthis.subordinate = options.template.l === 1;\n\t\tthis.fragment = null;\n\t}\n\n\tbind () {\n\t\tsuper.bind();\n\n\t\tif ( this.subordinate ) {\n\t\t\tthis.sibling = this.parentFragment.items[ this.parentFragment.items.indexOf( this ) - 1 ];\n\t\t\tthis.sibling.nextSibling = this;\n\t\t}\n\n\t\t// if we managed to bind, we need to create children\n\t\tif ( this.model ) {\n\t\t\tthis.dirty = true;\n\t\t\tthis.update();\n\t\t} else if ( this.sectionType && this.sectionType === SECTION_UNLESS && ( !this.sibling || !this.sibling.isTruthy() ) ) {\n\t\t\tthis.fragment = new Fragment({\n\t\t\t\towner: this,\n\t\t\t\ttemplate: this.template.f\n\t\t\t}).bind();\n\t\t}\n\t}\n\n\tdetach () {\n\t\tconst frag = this.fragment || this.detached;\n\t\treturn frag ? frag.detach() : super.detach();\n\t}\n\n\tisTruthy () {\n\t\tif ( this.subordinate && this.sibling.isTruthy() ) return true;\n\t\tconst value = !this.model ? undefined : this.model.isRoot ? this.model.value : this.model.get();\n\t\treturn !!value && ( this.templateSectionType === SECTION_IF_WITH || !isEmpty( value ) );\n\t}\n\n\trebind ( next, previous, safe ) {\n\t\tif ( super.rebind( next, previous, safe ) ) {\n\t\t\tif ( this.fragment && this.sectionType !== SECTION_IF && this.sectionType !== SECTION_UNLESS ) {\n\t\t\t\tthis.fragment.rebind( next );\n\t\t\t}\n\t\t}\n\t}\n\n\trender ( target, occupants ) {\n\t\tthis.rendered = true;\n\t\tif ( this.fragment ) this.fragment.render( target, occupants );\n\t}\n\n\tshuffle ( newIndices ) {\n\t\tif ( this.fragment && this.sectionType === SECTION_EACH ) {\n\t\t\tthis.fragment.shuffle( newIndices );\n\t\t}\n\t}\n\n\tunbind () {\n\t\tsuper.unbind();\n\t\tif ( this.fragment ) this.fragment.unbind();\n\t}\n\n\tunrender ( shouldDestroy ) {\n\t\tif ( this.rendered && this.fragment ) this.fragment.unrender( shouldDestroy );\n\t\tthis.rendered = false;\n\t}\n\n\tupdate () {\n\t\tif ( !this.dirty ) return;\n\n\t\tif ( this.fragment && this.sectionType !== SECTION_IF && this.sectionType !== SECTION_UNLESS ) {\n\t\t\tthis.fragment.context = this.model;\n\t\t}\n\n\t\tif ( !this.model && this.sectionType !== SECTION_UNLESS ) return;\n\n\t\tthis.dirty = false;\n\n\t\tconst value = !this.model ? undefined : this.model.isRoot ? this.model.value : this.model.get();\n\t\tconst siblingFalsey = !this.subordinate || !this.sibling.isTruthy();\n\t\tconst lastType = this.sectionType;\n\n\t\t// watch for switching section types\n\t\tif ( this.sectionType === null || this.templateSectionType === null ) this.sectionType = getType( value, this.template.i );\n\t\tif ( lastType && lastType !== this.sectionType && this.fragment ) {\n\t\t\tif ( this.rendered ) {\n\t\t\t\tthis.fragment.unbind().unrender( true );\n\t\t\t}\n\n\t\t\tthis.fragment = null;\n\t\t}\n\n\t\tlet newFragment;\n\n\t\tconst fragmentShouldExist = this.sectionType === SECTION_EACH || // each always gets a fragment, which may have no iterations\n\t\t this.sectionType === SECTION_WITH || // with (partial context) always gets a fragment\n\t\t ( siblingFalsey && ( this.sectionType === SECTION_UNLESS ? !this.isTruthy() : this.isTruthy() ) ); // if, unless, and if-with depend on siblings and the condition\n\n\t\tif ( fragmentShouldExist ) {\n\t\t\tif ( !this.fragment ) this.fragment = this.detached;\n\n\t\t\tif ( this.fragment ) {\n\t\t\t\t// check for detached fragment\n\t\t\t\tif ( this.detached ) {\n\t\t\t\t\tattach( this, this.fragment );\n\t\t\t\t\tthis.detached = false;\n\t\t\t\t\tthis.rendered = true;\n\t\t\t\t}\n\n\t\t\t\tthis.fragment.update();\n\t\t\t} else {\n\t\t\t\tif ( this.sectionType === SECTION_EACH ) {\n\t\t\t\t\tnewFragment = new RepeatedFragment({\n\t\t\t\t\t\towner: this,\n\t\t\t\t\t\ttemplate: this.template.f,\n\t\t\t\t\t\tindexRef: this.template.i\n\t\t\t\t\t}).bind( this.model );\n\t\t\t\t} else {\n\t\t\t\t\t// only with and if-with provide context - if and unless do not\n\t\t\t\t\tconst context = this.sectionType !== SECTION_IF && this.sectionType !== SECTION_UNLESS ? this.model : null;\n\t\t\t\t\tnewFragment = new Fragment({\n\t\t\t\t\t\towner: this,\n\t\t\t\t\t\ttemplate: this.template.f\n\t\t\t\t\t}).bind( context );\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif ( this.fragment && this.rendered ) {\n\t\t\t\tif ( keep !== true ) {\n\t\t\t\t\tthis.fragment.unbind().unrender( true );\n\t\t\t\t} else {\n\t\t\t\t\tthis.unrender( false );\n\t\t\t\t\tthis.detached = this.fragment;\n\t\t\t\t\trunloop.scheduleTask( () => this.detach() );\n\t\t\t\t}\n\t\t\t} else if ( this.fragment ) {\n\t\t\t\tthis.fragment.unbind();\n\t\t\t}\n\n\t\t\tthis.fragment = null;\n\t\t}\n\n\t\tif ( newFragment ) {\n\t\t\tif ( this.rendered ) {\n\t\t\t\tattach( this, newFragment );\n\t\t\t}\n\n\t\t\tthis.fragment = newFragment;\n\t\t}\n\n\t\tif ( this.nextSibling ) {\n\t\t\tthis.nextSibling.dirty = true;\n\t\t\tthis.nextSibling.update();\n\t\t}\n\t}\n}\n\nfunction attach ( section, fragment ) {\n\tconst anchor = section.parentFragment.findNextNode( section );\n\n\tif ( anchor ) {\n\t\tconst docFrag = createDocumentFragment();\n\t\tfragment.render( docFrag );\n\n\t\tanchor.parentNode.insertBefore( docFrag, anchor );\n\t} else {\n\t\tfragment.render( section.parentFragment.findParentNode() );\n\t}\n}\n","import Element from '../../Element';\nimport { toArray } from '../../../../utils/array';\nimport getSelectedOptions from '../../../../utils/getSelectedOptions';\n\nexport default class Select extends Element {\n\tconstructor ( options ) {\n\t\tsuper( options );\n\t\tthis.options = [];\n\t}\n\n\tfoundNode ( node ) {\n\t\tif ( this.binding ) {\n\t\t\tconst selectedOptions = getSelectedOptions( node );\n\n\t\t\tif ( selectedOptions.length > 0 ) {\n\t\t\t\tthis.selectedOptions = selectedOptions;\n\t\t\t}\n\t\t}\n\t}\n\n\trender ( target, occupants ) {\n\t\tsuper.render( target, occupants );\n\t\tthis.sync();\n\n\t\tconst node = this.node;\n\n\t\tlet i = node.options.length;\n\t\twhile ( i-- ) {\n\t\t\tnode.options[i].defaultSelected = node.options[i].selected;\n\t\t}\n\n\t\tthis.rendered = true;\n\t}\n\n\tsync () {\n\t\tconst selectNode = this.node;\n\n\t\tif ( !selectNode ) return;\n\n\t\tconst options = toArray( selectNode.options );\n\n\t\tif ( this.selectedOptions ) {\n\t\t\toptions.forEach( o => {\n\t\t\t\tif ( this.selectedOptions.indexOf( o ) >= 0 ) o.selected = true;\n\t\t\t\telse o.selected = false;\n\t\t\t});\n\t\t\tthis.binding.setFromNode( selectNode );\n\t\t\tdelete this.selectedOptions;\n\t\t\treturn;\n\t\t}\n\n\t\tconst selectValue = this.getAttribute( 'value' );\n\t\tconst isMultiple = this.getAttribute( 'multiple' );\n\t\tconst array = isMultiple && Array.isArray( selectValue );\n\n\t\t// If the ', '' ]\n\t};\n}\n\nexport default function ( html, node ) {\n\tconst nodes = [];\n\n\t// render 0 and false\n\tif ( html == null || html === '' ) return nodes;\n\n\tlet container;\n\tlet wrapper;\n\tlet selectedOption;\n\n\t/* istanbul ignore if */\n\tif ( ieBug && ( wrapper = ieBlacklist[ node.tagName ] ) ) {\n\t\tcontainer = element( 'DIV' );\n\t\tcontainer.innerHTML = wrapper[0] + html + wrapper[1];\n\t\tcontainer = container.querySelector( '.x' );\n\n\t\tif ( container.tagName === 'SELECT' ) {\n\t\t\tselectedOption = container.options[ container.selectedIndex ];\n\t\t}\n\t}\n\n\telse if ( node.namespaceURI === svg ) {\n\t\tcontainer = element( 'DIV' );\n\t\tcontainer.innerHTML = '' + html + '';\n\t\tcontainer = container.querySelector( '.x' );\n\t}\n\n\telse if ( node.tagName === 'TEXTAREA' ) {\n\t\tcontainer = createElement( 'div' );\n\n\t\tif ( typeof container.textContent !== 'undefined' ) {\n\t\t\tcontainer.textContent = html;\n\t\t} else {\n\t\t\tcontainer.innerHTML = html;\n\t\t}\n\t}\n\n\telse {\n\t\tcontainer = element( node.tagName );\n\t\tcontainer.innerHTML = html;\n\n\t\tif ( container.tagName === 'SELECT' ) {\n\t\t\tselectedOption = container.options[ container.selectedIndex ];\n\t\t}\n\t}\n\n\tlet child;\n\twhile ( child = container.firstChild ) {\n\t\tnodes.push( child );\n\t\tcontainer.removeChild( child );\n\t}\n\n\t// This is really annoying. Extracting