{"version":3,"file":"ractive.js","sources":["../src/Ractive.js","../src/Ractive/static/findPlugin.js","../src/Ractive/static/keypaths.js","../src/extend/_macro.js","../src/extend/_extend.js","../src/Ractive/static/use.js","../src/Ractive/static/sharedGet.js","../src/Ractive/static/sharedSet.js","../src/Ractive/static/styles.js","../src/Ractive/static/styleGet.js","../src/Ractive/static/isInstance.js","../src/Ractive/prototype.js","../src/Ractive/prototype/use.js","../src/Ractive/prototype/updateModel.js","../src/Ractive/prototype/unshift.js","../src/Ractive/prototype/unrender.js","../src/Ractive/prototype/unlink.js","../src/Ractive/prototype/transition.js","../src/Ractive/prototype/toText.js","../src/Ractive/prototype/toHTML.js","../src/Ractive/prototype/toCSS.js","../src/Ractive/prototype/toggle.js","../src/Ractive/prototype/subtract.js","../src/Ractive/prototype/splice.js","../src/Ractive/prototype/sort.js","../src/Ractive/prototype/shift.js","../src/Ractive/prototype/set.js","../src/Ractive/prototype/reverse.js","../src/Ractive/prototype/resetTemplate.js","../src/Ractive/prototype/resetPartial.js","../src/Ractive/prototype/reset.js","../src/Ractive/prototype/render.js","../src/Ractive/render.js","../src/Ractive/initialise.js","../src/events/HookQueue.js","../src/view/Fragment.js","../src/view/helpers/processItems.js","../src/view/items/createItem.js","../src/view/items/Await.js","../src/view/items/asyncProxy.js","../src/view/items/component/getComponentConstructor.js","../src/view/items/Triple.js","../src/view/items/triple/insertHtml.js","../src/view/items/element/Transition.js","../src/view/items/element/transitions/createTransitions.js","../src/view/items/element/transitions/hyphenate.js","../src/view/items/element/transitions/prefix.js","../src/config/visibility.js","../src/view/items/Text.js","../src/view/items/element/specials/Textarea.js","../src/view/items/element/specials/Select.js","../src/view/items/Section.js","../src/view/RepeatedFragment.js","../src/model/specials/KeyModel.js","../src/view/items/Partial.js","../src/view/items/partial/getPartialTemplate.js","../src/view/items/element/specials/Option.js","../src/view/items/component/Mapping.js","../src/utils/parseJSON.js","../src/view/items/element/specials/Input.js","../src/view/items/Interpolator.js","../src/view/items/shared/Mustache.js","../src/view/items/shared/progressiveText.js","../src/view/items/shared/EventDirective.js","../src/view/items/component/RactiveEvent.js","../src/view/items/element/ElementEvents.js","../src/view/items/element/specials/Form.js","../src/view/items/Element.js","../src/view/items/element/binding/selectBinding.js","../src/view/items/element/binding/SingleSelectBinding.js","../src/view/items/element/binding/RadioNameBinding.js","../src/view/items/element/binding/RadioBinding.js","../src/view/items/element/binding/NumericBinding.js","../src/view/items/element/binding/MultipleSelectBinding.js","../src/utils/getSelectedOptions.js","../src/view/items/element/binding/FileBinding.js","../src/view/items/element/binding/GenericBinding.js","../src/view/items/element/binding/ContentEditableBinding.js","../src/view/items/element/binding/CheckboxNameBinding.js","../src/view/items/element/binding/getBindingGroup.js","../src/view/items/element/binding/CheckboxBinding.js","../src/view/items/element/binding/handleDomEvent.js","../src/view/items/element/binding/Binding.js","../src/view/items/Doctype.js","../src/view/items/element/Decorator.js","../src/view/items/shared/directiveArgs.js","../src/view/items/Component.js","../src/Ractive/construct.js","../src/Ractive/helpers/subscribe.js","../src/model/RootModel.js","../src/model/specials/RactiveModel.js","../src/Ractive/prototype/teardown.js","../src/view/items/Comment.js","../src/view/items/element/BindingFlag.js","../src/view/items/element/Attribute.js","../src/view/items/element/ConditionalAttribute.js","../src/view/items/element/attribute/propertyNames.js","../src/view/items/element/attribute/getUpdateDelegate.js","../src/view/helpers/specialAttrs.js","../src/utils/hyphenateCamel.js","../src/view/items/Alias.js","../src/view/resolvers/resolve.js","../src/view/resolvers/ReferenceExpressionProxy.js","../src/view/resolvers/ExpressionProxy.js","../src/model/Computation.js","../src/model/ComputationChild.js","../src/view/items/shared/Item.js","../src/Ractive/config/config.js","../src/Ractive/config/deprecate.js","../src/Ractive/config/wrapPrototypeMethod.js","../src/Ractive/config/registries.js","../src/Ractive/config/custom/template.js","../src/Ractive/config/custom/data.js","../src/Ractive/config/custom/css/css.js","../src/model/specials/CSSModel.js","../src/Ractive/static/styleSet.js","../src/utils/id.js","../src/Ractive/config/custom/css/transform.js","../src/utils/cleanCss.js","../src/Ractive/config/custom/adapt.js","../src/global/css.js","../src/Ractive/prototype/readLink.js","../src/Ractive/prototype/push.js","../src/Ractive/prototype/pop.js","../src/Ractive/prototype/once.js","../src/Ractive/prototype/on.js","../src/Ractive/prototype/off.js","../src/Ractive/prototype/shared/notEmptyString.js","../src/Ractive/prototype/shared/trim.js","../src/Ractive/prototype/observeOnce.js","../src/Ractive/prototype/observe.js","../src/Ractive/prototype/observe/Array.js","../src/Ractive/prototype/observe/Pattern.js","../src/Ractive/prototype/observe/Observer.js","../src/Ractive/prototype/link.js","../src/Ractive/prototype/insert.js","../src/utils/dom.js","../src/config/namespaces.js","../src/Ractive/prototype/getContext.js","../src/Ractive/static/getContext.js","../src/Ractive/prototype/get.js","../src/Ractive/prototype/fire.js","../src/shared/Context.js","../src/Ractive/prototype/update.js","../src/Ractive/prototype/shared/makeArrayMethod.js","../src/shared/getNewIndices.js","../src/view/items/shared/findElement.js","../src/Ractive/prototype/findParent.js","../src/Ractive/prototype/findContainer.js","../src/Ractive/prototype/findComponent.js","../src/Ractive/prototype/findAllComponents.js","../src/Ractive/prototype/findAll.js","../src/Ractive/prototype/find.js","../src/Ractive/prototype/detachChild.js","../src/Ractive/prototype/detach.js","../src/Ractive/prototype/compute.js","../src/Ractive/prototype/attachChild.js","../src/shared/anchors.js","../src/events/Hook.js","../src/events/fireEvent.js","../src/events/eventStack.js","../src/Ractive/prototype/animate.js","../src/Ractive/prototype/add.js","../src/Ractive/prototype/shared/add.js","../src/shared/set.js","../src/shared/getRactiveContext.js","../src/view/resolvers/resolveReference.js","../src/model/specials/SharedModel.js","../src/model/Model.js","../src/model/helpers/getPrefixer.js","../src/shared/Ticker.js","../src/global/runloop.js","../src/global/TransitionManager.js","../src/Ractive/helpers/getComputationSignature.js","../src/Ractive/config/runtime-parser.js","../src/parse/_parse.js","../src/Ractive/shared.js","../src/parse/utils/insertExpressions.js","../src/parse/converters/readTemplate.js","../src/parse/converters/readPartialDefinitionSection.js","../src/parse/converters/readText.js","../src/parse/converters/readElement.js","../src/parse/converters/element/readClosingTag.js","../src/parse/utils/cleanup.js","../src/parse/utils/trimWhitespace.js","../src/parse/utils/stripStandalones.js","../src/parse/converters/readHtmlComment.js","../src/parse/converters/mustache/readSection.js","../src/parse/converters/mustache/handlebarsBlockCodes.js","../src/parse/converters/mustache/section/readInlineBlock.js","../src/parse/converters/mustache/section/readClosing.js","../src/parse/converters/mustache/readInterpolator.js","../src/parse/converters/mustache/readMustacheComment.js","../src/parse/converters/mustache/readPartial.js","../src/parse/converters/mustache/readAliases.js","../src/parse/converters/mustache/readUnescaped.js","../src/parse/converters/mustache/readTriple.js","../src/parse/converters/readMustache.js","../src/parse/converters/element/readAttribute.js","../src/parse/utils/refineExpression.js","../src/parse/utils/flattenExpression.js","../src/parse/converters/readExpressionOrReference.js","../src/parse/converters/expressions/shared/readExpressionList.js","../src/parse/converters/readExpression.js","../src/parse/converters/expressions/readConditional.js","../src/parse/converters/expressions/readLogicalOr.js","../src/parse/converters/expressions/readTypeof.js","../src/parse/converters/expressions/readMemberOrInvocation.js","../src/parse/converters/expressions/shared/readRefinement.js","../src/parse/converters/expressions/readPrimary.js","../src/parse/converters/expressions/primary/readBracketedExpression.js","../src/parse/converters/expressions/primary/readReference.js","../src/parse/converters/expressions/primary/readLiteral.js","../src/parse/converters/expressions/primary/literal/readArrayLiteral.js","../src/parse/converters/expressions/primary/literal/readObjectLiteral.js","../src/parse/converters/expressions/primary/literal/objectLiteral/keyValuePairs.js","../src/parse/converters/expressions/primary/literal/objectLiteral/keyValuePair.js","../src/parse/converters/expressions/shared/readKey.js","../src/parse/converters/expressions/shared/patterns.js","../src/parse/converters/expressions/primary/literal/readTemplateStringLiteral.js","../src/parse/converters/expressions/primary/literal/readStringLiteral.js","../src/parse/converters/expressions/primary/literal/stringLiteral/makeQuotedStringMatcher.js","../src/parse/converters/expressions/primary/literal/readBooleanLiteral.js","../src/parse/converters/expressions/primary/literal/readNumberLiteral.js","../src/parse/converters/expressions/shared/errors.js","../src/utils/html.js","../src/parse/converters/utils/getLowestIndex.js","../src/utils/escapeRegExp.js","../src/parse/converters/expressions/primary/literal/readRegexpLiteral.js","../src/parse/converters/mustache/readDelimiterChange.js","../src/config/types.js","../src/parse/Parser.js","../src/config/template.js","../src/shared/getFunction.js","../src/parse/utils/createFunction.js","../src/model/LinkModel.js","../src/shared/rebind.js","../src/shared/methodCallers.js","../src/global/capture.js","../src/model/ModelBase.js","../src/utils/bind.js","../src/utils/array.js","../src/shared/keypaths.js","../src/Ractive/static/interpolators.js","../src/shared/interpolate.js","../src/shared/registry.js","../src/config/errors.js","../src/utils/log.js","../src/utils/noop.js","../src/config/environment.js","../src/Ractive/static/easing.js","../src/Ractive/config/defaults.js","../src/polyfills/requestAnimationFrame.js","../src/polyfills/Promise.js","../src/polyfills/performance.now.js","../src/polyfills/node.contains.js","../src/polyfills/array.find.js","../src/utils/is.js","../src/utils/object.js","../src/polyfills/Object.assign.js"],"sourcesContent":["import './polyfills/Object.assign';\nimport './polyfills/array.find';\nimport './polyfills/node.contains';\nimport './polyfills/performance.now';\nimport './polyfills/Promise';\nimport './polyfills/requestAnimationFrame';\n\nimport defaults from './Ractive/config/defaults';\nimport easing from './Ractive/static/easing';\nimport interpolators from './Ractive/static/interpolators';\nimport { svg, win } from './config/environment';\nimport proto from './Ractive/prototype';\nimport { extend, extendWith } from './extend/_extend';\nimport macro from './extend/_macro';\nimport parse from './parse/_parse';\nimport getContext, { getNodeInfo } from './Ractive/static/getContext';\nimport isInstance from './Ractive/static/isInstance';\nimport use from './Ractive/static/use';\nimport construct from './Ractive/construct';\nimport initialise from './Ractive/initialise';\nimport { getCSS } from './global/css';\nimport { escapeKey, unescapeKey, normalise } from './shared/keypaths';\nimport { joinKeys, splitKeypath } from './Ractive/static/keypaths';\nimport shared from './Ractive/shared';\nimport { findPlugin } from './Ractive/static/findPlugin';\nimport parseJSON from './utils/parseJSON';\nimport CSSModel from './model/specials/CSSModel';\nimport { data as sharedData } from './model/specials/SharedModel';\nimport { extern } from './shared/getRactiveContext';\nimport { warn } from 'utils/log';\n\nimport { assign, defineProperty, defineProperties } from 'utils/object';\n\nexport default function Ractive(options) {\n if (!(this instanceof Ractive)) return new Ractive(options);\n\n construct(this, options || {});\n initialise(this, options || {}, {});\n}\n\n// check to see if we're being asked to force Ractive as a global for some weird environments\nif (win && !win.Ractive) {\n let opts = '';\n const script =\n document.currentScript ||\n /* istanbul ignore next */ document.querySelector('script[data-ractive-options]');\n\n if (script) opts = script.getAttribute('data-ractive-options') || '';\n\n /* istanbul ignore next */\n if (~opts.indexOf('ForceGlobal')) win.Ractive = Ractive;\n} else if (win) {\n warn(`Ractive already appears to be loaded while loading BUILD_PLACEHOLDER_VERSION.`);\n}\n\nassign(Ractive.prototype, proto, defaults);\nRactive.prototype.constructor = Ractive;\n\n// alias prototype as `defaults`\nRactive.defaults = Ractive.prototype;\n\n// share defaults with the parser\nshared.defaults = Ractive.defaults;\nshared.Ractive = Ractive;\n\n// static properties\ndefineProperties(Ractive, {\n // debug flag\n DEBUG: { writable: true, value: true },\n DEBUG_PROMISES: { writable: true, value: true },\n\n // static methods:\n extend: { value: extend },\n extendWith: { value: extendWith },\n escapeKey: { value: escapeKey },\n evalObjectString: { value: parseJSON },\n findPlugin: { value: findPlugin },\n getContext: { value: getContext },\n getCSS: { value: getCSS },\n getNodeInfo: { value: getNodeInfo },\n isInstance: { value: isInstance },\n joinKeys: { value: joinKeys },\n macro: { value: macro },\n normaliseKeypath: { value: normalise },\n parse: { value: parse },\n splitKeypath: { value: splitKeypath },\n // sharedSet and styleSet are in _extend because circular refs\n unescapeKey: { value: unescapeKey },\n use: { value: use },\n\n // support\n enhance: { writable: true, value: false },\n svg: { value: svg },\n\n // version\n VERSION: { value: 'BUILD_PLACEHOLDER_VERSION' },\n\n // plugins\n adaptors: { writable: true, value: {} },\n components: { writable: true, value: {} },\n decorators: { writable: true, value: {} },\n easing: { writable: true, value: easing },\n events: { writable: true, value: {} },\n extensions: { value: [] },\n helpers: { writable: true, value: defaults.helpers },\n interpolators: { writable: true, value: interpolators },\n partials: { writable: true, value: {} },\n transitions: { writable: true, value: {} },\n\n // CSS variables\n cssData: { configurable: true, value: {} },\n\n // access to @shared without an instance\n sharedData: { value: sharedData },\n\n // for getting the source Ractive lib from a constructor\n Ractive: { value: Ractive },\n\n // to allow extending contexts\n Context: { value: extern.Context.prototype }\n});\n\n// cssData must already be in place\ndefineProperty(Ractive, '_cssModel', {\n configurable: true,\n value: new CSSModel(Ractive)\n});\n","import { findInViewHierarchy } from 'shared/registry';\n\nexport function findPlugin(name, type, instance) {\n return findInViewHierarchy(type, instance, name);\n}\n","import { escapeKey, splitKeypath as splitKeypathI, unescapeKey } from 'shared/keypaths';\n\nexport function joinKeys(...keys) {\n return keys.map(escapeKey).join('.');\n}\n\nexport function splitKeypath(keypath) {\n return splitKeypathI(keypath).map(unescapeKey);\n}\n","import styleGet from '../Ractive/static/styleGet';\nimport styleSet from '../Ractive/static/styleSet';\nimport CSSModel from 'src/model/specials/CSSModel';\nimport { assign, create, defineProperties, defineProperty } from 'utils/object';\nimport { isFunction } from 'utils/is';\n\nimport { initCSS } from 'src/Ractive/config/custom/css/css';\n\nexport default function macro(fn, opts) {\n if (!isFunction(fn)) throw new Error(`The macro must be a function`);\n\n assign(fn, opts);\n\n defineProperties(fn, {\n extensions: { value: [] },\n _cssIds: { value: [] },\n cssData: { value: assign(create(this.cssData), fn.cssData || {}) },\n\n styleGet: { value: styleGet.bind(fn) },\n styleSet: { value: styleSet.bind(fn) }\n });\n\n defineProperty(fn, '_cssModel', { value: new CSSModel(fn) });\n\n if (fn.css) initCSS(fn, fn, fn);\n\n this.extensions.push(fn);\n\n return fn;\n}\n","import config from '../Ractive/config/config';\nimport dataConfigurator from '../Ractive/config/custom/data';\nimport construct from '../Ractive/construct';\nimport initialise from '../Ractive/initialise';\nimport Ractive from '../Ractive';\nimport isInstance from '../Ractive/static/isInstance';\nimport styleSet from '../Ractive/static/styleSet';\nimport styleGet from '../Ractive/static/styleGet';\nimport { addStyle, hasStyle } from '../Ractive/static/styles';\nimport sharedSet from '../Ractive/static/sharedSet';\nimport sharedGet from '../Ractive/static/sharedGet';\nimport use from '../Ractive/static/use';\nimport { create, defineProperties, toPairs, defineProperty } from 'utils/object';\nimport { isArray, isFunction } from 'utils/is';\n\nconst callsSuper = /super\\s*\\(|\\.call\\s*\\(\\s*this/;\n\nexport function extend(...options) {\n if (!options.length) {\n return extendOne(this);\n } else {\n return options.reduce(extendOne, this);\n }\n}\n\nexport function extendWith(Class, options = {}) {\n return extendOne(this, options, Class);\n}\n\nfunction extendOne(Parent, options = {}, Target) {\n let proto;\n let Child = isFunction(Target) && Target;\n\n if (options.prototype instanceof Ractive) {\n throw new Error(`Ractive no longer supports multiple inheritance.`);\n }\n\n if (Child) {\n if (!(Child.prototype instanceof Parent)) {\n throw new Error(\n `Only classes that inherit the appropriate prototype may be used with extend`\n );\n }\n if (!callsSuper.test(Child.toString())) {\n throw new Error(`Only classes that call super in their constructor may be used with extend`);\n }\n\n proto = Child.prototype;\n } else {\n Child = function(options) {\n if (!(this instanceof Child)) return new Child(options);\n\n construct(this, options || {});\n initialise(this, options || {}, {});\n };\n\n proto = create(Parent.prototype);\n proto.constructor = Child;\n\n Child.prototype = proto;\n }\n\n // Static properties\n defineProperties(Child, {\n // alias prototype as defaults\n defaults: { value: proto },\n\n extend: { value: extend, writable: true, configurable: true },\n extendWith: { value: extendWith, writable: true, configurable: true },\n extensions: { value: [] },\n use: { value: use },\n\n isInstance: { value: isInstance },\n\n Parent: { value: Parent },\n Ractive: { value: Ractive },\n\n styleGet: { value: styleGet.bind(Child), configurable: true },\n styleSet: { value: styleSet.bind(Child), configurable: true }\n });\n\n // extend configuration\n config.extend(Parent, proto, options, Child);\n\n // store event and observer registries on the constructor when extending\n Child._on = (Parent._on || []).concat(toPairs(options.on));\n Child._observe = (Parent._observe || []).concat(toPairs(options.observe));\n\n Parent.extensions.push(Child);\n\n // attribute defs are not inherited, but they need to be stored\n if (options.attributes) {\n let attrs;\n\n // allow an array of optional props or an object with arrays for optional and required props\n if (isArray(options.attributes)) {\n attrs = { optional: options.attributes, required: [] };\n } else {\n attrs = options.attributes;\n }\n\n // make sure the requisite keys actually store arrays\n if (!isArray(attrs.required)) attrs.required = [];\n if (!isArray(attrs.optional)) attrs.optional = [];\n\n Child.attributes = attrs;\n }\n\n dataConfigurator.extend(Parent, proto, options, Child);\n\n defineProperty(Child, 'helpers', { writable: true, value: proto.helpers });\n\n if (isArray(options.use)) Child.use.apply(Child, options.use);\n\n return Child;\n}\n\ndefineProperties(Ractive, {\n sharedGet: { value: sharedGet },\n sharedSet: { value: sharedSet },\n styleGet: { configurable: true, value: styleGet.bind(Ractive) },\n styleSet: { configurable: true, value: styleSet.bind(Ractive) },\n addCSS: { configurable: false, value: addStyle.bind(Ractive) },\n hasCSS: { configurable: false, value: hasStyle.bind(Ractive) }\n});\n","import { isFunction } from 'utils/is';\n\nexport default function use(...plugins) {\n plugins.forEach(p => {\n isFunction(p) &&\n p({\n proto: this.prototype,\n Ractive: this.Ractive,\n instance: this\n });\n });\n return this;\n}\n","import SharedModel from '../../model/specials/SharedModel';\nimport { splitKeypath } from 'shared/keypaths';\n\nexport default function sharedGet(keypath) {\n return SharedModel.joinAll(splitKeypath(keypath)).get();\n}\n","import { build, set } from '../../shared/set';\nimport SharedModel from '../../model/specials/SharedModel';\nimport { isObjectType } from 'utils/is';\n\nexport default function sharedSet(keypath, value, options) {\n const opts = isObjectType(keypath) ? value : options;\n const model = SharedModel;\n\n return set(build({ viewmodel: model }, keypath, value, true), opts);\n}\n","import { isFunction } from 'utils/is';\nimport { addCSS, applyCSS } from 'src/global/css';\nimport { recomputeCSS } from './styleSet';\n\nconst styles = [];\n\nexport function addStyle(id, css) {\n if (styles.find(s => s.id === id))\n throw new Error(`Extra styles with the id '${id}' have already been added.`);\n styles.push({ id, css });\n\n if (!this.css) {\n Object.defineProperty(this, 'css', { configurable: false, writable: false, value: buildCSS });\n }\n\n if (!this._cssDef) {\n Object.defineProperty(this, '_cssDef', {\n configurable: true,\n writable: false,\n value: {\n transform: false,\n id: 'Ractive.addStyle'\n }\n });\n\n addCSS(this._cssDef);\n }\n\n recomputeCSS(this);\n applyCSS(true);\n}\n\nfunction buildCSS(data) {\n return styles\n .map(s => `\\n/* ---- extra style ${s.id} */\\n` + (isFunction(s.css) ? s.css(data) : s.css))\n .join('');\n}\n\nexport function hasStyle(id) {\n return !!styles.find(s => s.id === id);\n}\n","import { splitKeypath } from 'shared/keypaths';\n\nexport default function styleGet(keypath) {\n return this._cssModel.joinAll(splitKeypath(keypath)).get();\n}\n","export default function isInstance(object) {\n return object && object instanceof this;\n}\n","import add from './prototype/add';\nimport animate from './prototype/animate';\nimport attachChild from './prototype/attachChild';\nimport compute from './prototype/compute';\nimport detach from './prototype/detach';\nimport detachChild from './prototype/detachChild';\nimport find from './prototype/find';\nimport findAll from './prototype/findAll';\nimport findAllComponents from './prototype/findAllComponents';\nimport findComponent from './prototype/findComponent';\nimport findContainer from './prototype/findContainer';\nimport findParent from './prototype/findParent';\nimport fire from './prototype/fire';\nimport get from './prototype/get';\nimport getContext, { getNodeInfo } from './prototype/getContext';\nimport insert from './prototype/insert';\nimport link from './prototype/link';\nimport observe from './prototype/observe';\nimport observeOnce from './prototype/observeOnce';\nimport off from './prototype/off';\nimport on from './prototype/on';\nimport once from './prototype/once';\nimport pop from './prototype/pop';\nimport push from './prototype/push';\nimport readLink from './prototype/readLink';\nimport render from './prototype/render';\nimport reset from './prototype/reset';\nimport resetPartial from './prototype/resetPartial';\nimport resetTemplate from './prototype/resetTemplate';\nimport reverse from './prototype/reverse';\nimport set from './prototype/set';\nimport shift from './prototype/shift';\nimport sort from './prototype/sort';\nimport splice from './prototype/splice';\nimport subtract from './prototype/subtract';\nimport teardown from './prototype/teardown';\nimport toggle from './prototype/toggle';\nimport toCSS from './prototype/toCSS';\nimport toHTML from './prototype/toHTML';\nimport toText from './prototype/toText';\nimport transition from './prototype/transition';\nimport unlink from './prototype/unlink';\nimport unrender from './prototype/unrender';\nimport unshift from './prototype/unshift';\nimport update from './prototype/update';\nimport updateModel from './prototype/updateModel';\nimport use from './prototype/use';\n\nimport { defineProperty } from 'utils/object';\n\nconst proto = {\n add,\n animate,\n attachChild,\n compute,\n detach,\n detachChild,\n find,\n findAll,\n findAllComponents,\n findComponent,\n findContainer,\n findParent,\n fire,\n get,\n getContext,\n getNodeInfo,\n insert,\n link,\n observe,\n observeOnce,\n off,\n on,\n once,\n pop,\n push,\n readLink,\n render,\n reset,\n resetPartial,\n resetTemplate,\n reverse,\n set,\n shift,\n sort,\n splice,\n subtract,\n teardown,\n toggle,\n toCSS,\n toCss: toCSS,\n toHTML,\n toHtml: toHTML,\n toText,\n transition,\n unlink,\n unrender,\n unshift,\n update,\n updateModel,\n use\n};\n\ndefineProperty(proto, 'target', {\n get() {\n return this.el;\n }\n});\n\nexport default proto;\n","export default function use(...plugins) {\n plugins.forEach(p => {\n p({\n proto: this,\n Ractive: this.constructor.Ractive,\n instance: this\n });\n });\n return this;\n}\n","import { splitKeypath } from 'shared/keypaths';\nimport runloop from 'src/global/runloop';\n\nexport default function Ractive$updateModel(keypath, cascade) {\n const promise = runloop.start();\n\n if (!keypath) {\n this.viewmodel.updateFromBindings(true);\n } else {\n this.viewmodel.joinAll(splitKeypath(keypath)).updateFromBindings(cascade !== false);\n }\n\n runloop.end();\n\n return promise;\n}\n","import makeArrayMethod from './shared/makeArrayMethod';\nexport default makeArrayMethod('unshift').path;\n","import Hook from 'src/events/Hook';\nimport { warnIfDebug } from 'utils/log';\nimport { removeFromArray } from 'utils/array';\nimport runloop from 'src/global/runloop';\n\nconst unrenderHook = new Hook('unrender');\n\nexport default function Ractive$unrender() {\n if (!this.fragment.rendered) {\n warnIfDebug('ractive.unrender() was called on a Ractive instance that was not rendered');\n return Promise.resolve();\n }\n\n this.unrendering = true;\n const promise = runloop.start();\n\n // If this is a component, and the component isn't marked for destruction,\n // don't detach nodes from the DOM unnecessarily\n const shouldDestroy =\n !this.component ||\n (this.component.anchor || {}).shouldDestroy ||\n this.component.shouldDestroy ||\n this.shouldDestroy;\n this.fragment.unrender(shouldDestroy);\n if (shouldDestroy) this.destroyed = true;\n\n removeFromArray(this.el.__ractive_instances__, this);\n\n unrenderHook.fire(this);\n\n runloop.end();\n this.unrendering = false;\n\n return promise;\n}\n","import { splitKeypath } from 'shared/keypaths';\nimport runloop from 'src/global/runloop';\n\nexport default function unlink(here) {\n const promise = runloop.start();\n this.viewmodel.joinAll(splitKeypath(here), { lastLink: false }).unlink();\n runloop.end();\n return promise;\n}\n","import runloop from 'src/global/runloop';\nimport Transition from '../../view/items/element/Transition';\nimport { fatal } from 'utils/log';\nimport { isObject } from 'utils/is';\n\nexport default function Ractive$transition(name, node, params) {\n if (node instanceof HTMLElement) {\n // good to go\n } else if (isObject(node)) {\n // omitted, use event node\n params = node;\n }\n\n // if we allow query selector, then it won't work\n // simple params like \"fast\"\n\n // else if ( typeof node === 'string' ) {\n // \t// query selector\n // \tnode = this.find( node )\n // }\n\n node = node || this.event.node;\n\n if (!node || !node._ractive) {\n fatal(`No node was supplied for transition ${name}`);\n }\n\n params = params || {};\n const owner = node._ractive.proxy;\n const transition = new Transition({ owner, up: owner.up, name, params });\n transition.bind();\n\n const promise = runloop.start();\n runloop.registerTransition(transition);\n runloop.end();\n\n promise.then(() => transition.unbind());\n return promise;\n}\n","export default function toText() {\n return this.fragment.toString(false);\n}\n","export default function Ractive$toHTML() {\n return this.fragment.toString(true);\n}\n","import { getCSS } from 'src/global/css';\nimport { keys } from 'utils/object';\n\nexport default function Ractive$toCSS() {\n const cssIds = [this.cssId, ...this.findAllComponents().map(c => c.cssId)];\n const uniqueCssIds = keys(cssIds.reduce((ids, id) => ((ids[id] = true), ids), {}));\n return getCSS(uniqueCssIds);\n}\n","import { badArguments } from 'config/errors';\nimport { gather, set } from 'shared/set';\nimport { isString } from 'utils/is';\n\nexport default function Ractive$toggle(keypath, options) {\n if (!isString(keypath)) {\n throw new TypeError(badArguments);\n }\n\n return set(\n gather(this, keypath, null, options && options.isolated).map(m => [m, !m.get()]),\n options\n );\n}\n","import add from './shared/add';\nimport { isNumber, isObjectType } from 'utils/is';\n\nexport default function Ractive$subtract(keypath, d, options) {\n const num = isNumber(d) ? -d : -1;\n const opts = isObjectType(d) ? d : options;\n return add(this, keypath, num, opts);\n}\n","import makeArrayMethod from './shared/makeArrayMethod';\nexport default makeArrayMethod('splice').path;\n","import makeArrayMethod from './shared/makeArrayMethod';\nexport default makeArrayMethod('sort').path;\n","import makeArrayMethod from './shared/makeArrayMethod';\nexport default makeArrayMethod('shift').path;\n","import { build, set } from 'shared/set';\nimport { isObjectType } from 'utils/is';\n\nexport default function Ractive$set(keypath, value, options) {\n const ractive = this;\n\n const opts = isObjectType(keypath) ? value : options;\n\n return set(build(ractive, keypath, value, opts && opts.isolated), opts);\n}\n","import makeArrayMethod from './shared/makeArrayMethod';\nexport default makeArrayMethod('reverse').path;\n","import { createDocumentFragment } from 'utils/dom';\nimport Fragment from 'src/view/Fragment';\nimport runloop from 'src/global/runloop';\nimport { default as templateConfigurator } from '../config/custom/template';\n\n// TODO should resetTemplate be asynchronous? i.e. should it be a case\n// of outro, update template, intro? I reckon probably not, since that\n// could be achieved with unrender-resetTemplate-render. Also, it should\n// conceptually be similar to resetPartial, which couldn't be async\n\nexport default function Ractive$resetTemplate(template) {\n templateConfigurator.init(null, this, { template });\n\n const transitionsEnabled = this.transitionsEnabled;\n this.transitionsEnabled = false;\n\n // Is this is a component, we need to set the `shouldDestroy`\n // flag, otherwise it will assume by default that a parent node\n // will be detached, and therefore it doesn't need to bother\n // detaching its own nodes\n const component = this.component;\n if (component) component.shouldDestroy = true;\n this.unrender();\n if (component) component.shouldDestroy = false;\n\n const promise = runloop.start();\n\n // remove existing fragment and create new one\n this.fragment.unbind().unrender(true);\n\n this.fragment = new Fragment({\n template: this.template,\n root: this,\n owner: this\n });\n\n const docFrag = createDocumentFragment();\n this.fragment.bind(this.viewmodel).render(docFrag);\n\n // if this is a component, its el may not be valid, so find a\n // target based on the component container\n if (component && !component.external) {\n this.fragment.findParentNode().insertBefore(docFrag, component.findNextNode());\n } else {\n this.el.insertBefore(docFrag, this.anchor);\n }\n\n runloop.end();\n\n this.transitionsEnabled = transitionsEnabled;\n\n return promise;\n}\n","import runloop from 'src/global/runloop';\nimport { PARTIAL, COMPONENT, ELEMENT } from 'config/types';\nimport { isArray } from 'utils/is';\nimport { handleChange } from 'shared/methodCallers';\n\nfunction collect(source, name, attr, dest) {\n source.forEach(item => {\n // queue to rerender if the item is a partial and the current name matches\n if (item.type === PARTIAL && (item.refName === name || item.name === name)) {\n item.inAttribute = attr;\n dest.push(item);\n return; // go no further\n }\n\n // if it has a fragment, process its items\n if (item.fragment) {\n collect(item.fragment.iterations || item.fragment.items, name, attr, dest);\n } else if (isArray(item.items)) {\n // or if it is itself a fragment, process its items\n collect(item.items, name, attr, dest);\n } else if (item.type === COMPONENT && item.instance) {\n // or if it is a component, step in and process its items\n // ...unless the partial is shadowed\n if (item.instance.partials[name]) return;\n collect(item.instance.fragment.items, name, attr, dest);\n }\n\n // if the item is an element, process its attributes too\n if (item.type === ELEMENT) {\n if (isArray(item.attributes)) {\n collect(item.attributes, name, true, dest);\n }\n }\n });\n}\n\nexport default function(name, partial) {\n const collection = [];\n collect(this.fragment.items, name, false, collection);\n\n const promise = runloop.start();\n\n this.partials[name] = partial;\n collection.forEach(handleChange);\n\n runloop.end();\n\n return promise;\n}\n","import runloop from 'src/global/runloop';\nimport config from '../config/config';\nimport Hook from '../../events/Hook';\nimport dataConfigurator from '../config/custom/data';\nimport { isObjectType } from 'utils/is';\n\nconst shouldRerender = ['template', 'partials', 'components', 'decorators', 'events'];\n\nconst completeHook = new Hook('complete');\nconst resetHook = new Hook('reset');\nconst renderHook = new Hook('render');\nconst unrenderHook = new Hook('unrender');\n\nexport default function Ractive$reset(data) {\n data = data || {};\n\n if (!isObjectType(data)) {\n throw new Error('The reset method takes either no arguments, or an object containing new data');\n }\n\n // TEMP need to tidy this up\n data = dataConfigurator.init(this.constructor, this, { data });\n\n const promise = runloop.start();\n\n // If the root object is wrapped, try and use the wrapper's reset value\n const wrapper = this.viewmodel.wrapper;\n if (wrapper && wrapper.reset) {\n if (wrapper.reset(data) === false) {\n // reset was rejected, we need to replace the object\n this.viewmodel.set(data);\n }\n } else {\n this.viewmodel.set(data);\n }\n\n // reset config items and track if need to rerender\n const changes = config.reset(this);\n let rerender;\n\n let i = changes.length;\n while (i--) {\n if (shouldRerender.indexOf(changes[i]) > -1) {\n rerender = true;\n break;\n }\n }\n\n if (rerender) {\n unrenderHook.fire(this);\n this.fragment.resetTemplate(this.template);\n renderHook.fire(this);\n completeHook.fire(this);\n }\n\n runloop.end();\n\n resetHook.fire(this, data);\n\n return promise;\n}\n","import { getElement } from 'utils/dom';\nimport { toArray } from 'utils/array';\nimport { warnIfDebug } from 'utils/log';\nimport render from '../render';\nimport { teardown } from 'shared/methodCallers';\n\nexport default function Ractive$render(target, anchor) {\n if (this.torndown) {\n warnIfDebug('ractive.render() was called on a Ractive instance that was already torn down');\n return Promise.resolve();\n }\n\n target = getElement(target) || this.el;\n\n if (!this.append && target) {\n // Teardown any existing instances *before* trying to set up the new one -\n // avoids certain weird bugs\n const others = target.__ractive_instances__;\n if (others) others.forEach(teardown);\n\n // make sure we are the only occupants\n if (!this.enhance) {\n target.innerHTML = ''; // TODO is this quicker than removeChild? Initial research inconclusive\n }\n }\n\n const occupants = this.enhance ? toArray(target.childNodes) : null;\n const promise = render(this, target, anchor, occupants);\n\n if (occupants) {\n while (occupants.length) target.removeChild(occupants.pop());\n }\n\n return promise;\n}\n","import { doc } from 'config/environment';\nimport { applyCSS } from 'src/global/css';\nimport Hook from 'src/events/Hook';\nimport { getElement } from 'utils/dom';\nimport runloop from 'src/global/runloop';\nimport { createFragment } from './initialise';\n\nconst renderHook = new Hook('render');\nconst completeHook = new Hook('complete');\n\nexport default function render(ractive, target, anchor, occupants) {\n // set a flag to let any transitions know that this instance is currently rendering\n ractive.rendering = true;\n\n const promise = runloop.start();\n runloop.scheduleTask(() => renderHook.fire(ractive), true);\n\n if (ractive.fragment.rendered) {\n throw new Error(\n 'You cannot call ractive.render() on an already rendered instance! Call ractive.unrender() first'\n );\n }\n\n if (ractive.destroyed) {\n ractive.destroyed = false;\n ractive.fragment = createFragment(ractive).bind(ractive.viewmodel);\n }\n\n anchor = getElement(anchor) || ractive.anchor;\n\n ractive.el = ractive.target = target;\n ractive.anchor = anchor;\n\n // ensure encapsulated CSS is up-to-date\n if (ractive.cssId) applyCSS();\n\n if (target) {\n (target.__ractive_instances__ || (target.__ractive_instances__ = [])).push(ractive);\n\n if (anchor) {\n const docFrag = doc.createDocumentFragment();\n ractive.fragment.render(docFrag);\n target.insertBefore(docFrag, anchor);\n } else {\n ractive.fragment.render(target, occupants);\n }\n }\n\n runloop.end();\n ractive.rendering = false;\n\n return promise.then(() => {\n if (ractive.torndown) return;\n\n completeHook.fire(ractive);\n });\n}\n","import { logIfDebug, warnIfDebug, warnOnceIfDebug } from 'utils/log';\nimport { getElement } from 'utils/dom';\nimport { isArray } from 'utils/is';\nimport config from './config/config';\nimport Fragment from 'src/view/Fragment';\nimport Hook from 'src/events/Hook';\nimport HookQueue from 'src/events/HookQueue';\nimport Ractive from '../Ractive';\nimport subscribe from './helpers/subscribe';\n\nconst configHook = new Hook('config');\nconst initHook = new HookQueue('init');\n\nexport default function initialise(ractive, userOptions, options) {\n // initialize settable computeds\n const computed = ractive.viewmodel.computed;\n if (computed) {\n for (const k in computed) {\n if (k in ractive.viewmodel.value && computed[k] && !computed[k].isReadonly) {\n computed[k].set(ractive.viewmodel.value[k]);\n }\n }\n }\n\n // init config from Parent and options\n config.init(ractive.constructor, ractive, userOptions);\n\n configHook.fire(ractive);\n\n initHook.begin(ractive);\n\n const fragment = (ractive.fragment = createFragment(ractive, options));\n if (fragment) fragment.bind(ractive.viewmodel);\n\n initHook.end(ractive);\n\n // general config done, set up observers\n subscribe(ractive, userOptions, 'observe');\n\n // call any passed in plugins\n if (isArray(userOptions.use))\n ractive.use.apply(ractive, userOptions.use.filter(p => !p.construct));\n\n if (fragment) {\n // render automatically ( if `el` is specified )\n const el = (ractive.el = ractive.target = getElement(ractive.el || ractive.target));\n if (el && !ractive.component) {\n const promise = ractive.render(el, ractive.append);\n\n if (Ractive.DEBUG_PROMISES) {\n promise.catch(err => {\n warnOnceIfDebug(\n 'Promise debugging is enabled, to help solve errors that happen asynchronously. Some browsers will log unhandled promise rejections, in which case you can safely disable promise debugging:\\n Ractive.DEBUG_PROMISES = false;'\n );\n warnIfDebug('An error happened during rendering', { ractive });\n logIfDebug(err);\n\n throw err;\n });\n }\n }\n }\n}\n\nexport function createFragment(ractive, options = {}) {\n if (ractive.template) {\n const cssIds = [].concat(ractive.constructor._cssIds || [], options.cssIds || []);\n\n return new Fragment({\n owner: ractive,\n template: ractive.template,\n cssIds\n });\n }\n}\n","import Hook from './Hook';\n\nfunction getChildQueue(queue, ractive) {\n return queue[ractive._guid] || (queue[ractive._guid] = []);\n}\n\nfunction fire(hookQueue, ractive) {\n const childQueue = getChildQueue(hookQueue.queue, ractive);\n\n hookQueue.hook.fire(ractive);\n\n // queue is \"live\" because components can end up being\n // added while hooks fire on parents that modify data values.\n while (childQueue.length) {\n fire(hookQueue, childQueue.shift());\n }\n\n delete hookQueue.queue[ractive._guid];\n}\n\nexport default class HookQueue {\n constructor(event) {\n this.hook = new Hook(event);\n this.inProcess = {};\n this.queue = {};\n }\n\n begin(ractive) {\n this.inProcess[ractive._guid] = true;\n }\n\n end(ractive) {\n const parent = ractive.parent;\n\n // If this is *isn't* a child of a component that's in process,\n // it should call methods or fire at this point\n if (!parent || !this.inProcess[parent._guid]) {\n fire(this, ractive);\n } else {\n // elsewise, handoff to parent to fire when ready\n getChildQueue(this.queue, parent).push(ractive);\n }\n\n delete this.inProcess[ractive._guid];\n }\n}\n","import { ELEMENT, YIELDER } from 'config/types';\nimport runloop from 'src/global/runloop';\nimport { findMap } from 'utils/array';\nimport { getContext, findParentWithContext } from 'shared/getRactiveContext';\nimport {\n bind,\n destroyed,\n shuffled,\n toEscapedString,\n toString,\n unbind,\n unrender,\n update\n} from 'shared/methodCallers';\nimport createItem from './items/createItem';\nimport processItems from './helpers/processItems';\nimport parseJSON from 'utils/parseJSON';\nimport { createDocumentFragment } from 'utils/dom';\nimport KeyModel from 'src/model/specials/KeyModel';\n\nfunction unrenderAndDestroy(item) {\n item.unrender(true);\n}\n\nexport default class Fragment {\n constructor(options) {\n this.owner = options.owner; // The item that owns this fragment - an element, section, partial, or attribute\n\n this.isRoot = !options.owner.up;\n this.parent = this.isRoot ? null : this.owner.up;\n this.ractive = options.ractive || (this.isRoot ? options.owner : this.parent.ractive);\n\n this.componentParent = this.isRoot && this.ractive.component ? this.ractive.component.up : null;\n if (!this.isRoot || this.ractive.delegate) {\n this.delegate = this.owner.containerFragment\n ? this.owner.containerFragment && this.owner.containerFragment.delegate\n : (this.componentParent && this.componentParent.delegate) ||\n (this.parent && this.parent.delegate);\n } else {\n this.delegate = false;\n }\n\n this.context = null;\n this.rendered = false;\n\n // encapsulated styles should be inherited until they get applied by an element\n if ('cssIds' in options) {\n this.cssIds = options.cssIds && options.cssIds.length && options.cssIds;\n } else {\n this.cssIds = this.parent ? this.parent.cssIds : null;\n }\n\n this.dirty = false;\n this.dirtyValue = true; // used for attribute values\n\n this.template = options.template || [];\n this.createItems();\n }\n\n bind(context) {\n this.context = context;\n this.items.forEach(bind);\n this.bound = true;\n\n // in rare cases, a forced resolution (or similar) will cause the\n // fragment to be dirty before it's even finished binding. In those\n // cases we update immediately\n if (this.dirty) this.update();\n\n return this;\n }\n\n bubble() {\n this.dirtyValue = true;\n\n if (!this.dirty) {\n this.dirty = true;\n\n if (this.isRoot) {\n // TODO encapsulate 'is component root, but not overall root' check?\n if (this.ractive.component) {\n this.ractive.component.bubble();\n } else if (this.bound) {\n runloop.addFragment(this);\n }\n } else {\n this.owner.bubble(this.index);\n }\n }\n }\n\n createItems() {\n // this is a hot code path\n const max = this.template.length;\n this.items = [];\n for (let i = 0; i < max; i++) {\n this.items[i] = createItem({\n up: this,\n template: this.template[i],\n index: i\n });\n }\n }\n\n destroyed() {\n this.items.forEach(destroyed);\n }\n\n detach() {\n const docFrag = createDocumentFragment();\n const xs = this.items;\n const len = xs.length;\n for (let i = 0; i < len; i++) {\n docFrag.appendChild(xs[i].detach());\n }\n return docFrag;\n }\n\n find(selector, options) {\n return findMap(this.items, i => i.find(selector, options));\n }\n\n findAll(selector, options) {\n if (this.items) {\n this.items.forEach(i => i.findAll && i.findAll(selector, options));\n }\n }\n\n findComponent(name, options) {\n return findMap(this.items, i => i.findComponent(name, options));\n }\n\n findAllComponents(name, options) {\n if (this.items) {\n this.items.forEach(i => i.findAllComponents && i.findAllComponents(name, options));\n }\n }\n\n findContext() {\n const base = findParentWithContext(this);\n if (!base || !base.context) return this.ractive.viewmodel;\n else return base.context;\n }\n\n findNextNode(item) {\n // search for the next node going forward\n if (item) {\n let it;\n for (let i = item.index + 1; i < this.items.length; i++) {\n it = this.items[i];\n if (!it || !it.firstNode) continue;\n\n const node = it.firstNode(true);\n if (node) return node;\n }\n }\n\n // if this is the root fragment, and there are no more items,\n // it means we're at the end...\n if (this.isRoot) {\n if (this.ractive.component) {\n return this.ractive.component.up.findNextNode(this.ractive.component);\n }\n\n // TODO possible edge case with other content\n // appended to this.ractive.el?\n return null;\n }\n\n if (this.parent) return this.owner.findNextNode(this); // the argument is in case the parent is a RepeatedFragment\n }\n\n findParentNode() {\n let fragment = this;\n\n do {\n if (fragment.owner.type === ELEMENT) {\n return fragment.owner.node;\n }\n\n if (fragment.isRoot && !fragment.ractive.component) {\n // TODO encapsulate check\n return fragment.ractive.el;\n }\n\n if (fragment.owner.type === YIELDER) {\n fragment = fragment.owner.containerFragment;\n } else {\n fragment = fragment.componentParent || fragment.parent; // TODO ugh\n }\n } while (fragment);\n\n throw new Error('Could not find parent node'); // TODO link to issue tracker\n }\n\n firstNode(skipParent) {\n const node = findMap(this.items, i => i.firstNode(true));\n if (node) return node;\n if (skipParent) return null;\n\n return this.parent.findNextNode(this.owner);\n }\n\n getKey() {\n return this.keyModel || (this.keyModel = new KeyModel(this.key));\n }\n\n getKeypath(root) {\n if (root) {\n return (\n this.rootModel ||\n (this.rootModel = new KeyModel(this.context.getKeypath(this.ractive.root)))\n );\n } else {\n return this.pathModel || (this.pathModel = new KeyModel(this.context.getKeypath()));\n }\n }\n\n getIndex() {\n return this.idxModel || (this.idxModel = new KeyModel(this.index));\n }\n\n rebind(next) {\n this.context = next;\n }\n\n render(target, occupants) {\n if (this.rendered) throw new Error('Fragment is already rendered!');\n this.rendered = true;\n\n const xs = this.items;\n const len = xs.length;\n for (let i = 0; i < len; i++) {\n xs[i].render(target, occupants);\n }\n }\n\n resetTemplate(template) {\n const wasBound = this.bound;\n const wasRendered = this.rendered;\n\n // TODO ensure transitions are disabled globally during reset\n\n if (wasBound) {\n if (wasRendered) this.unrender(true);\n this.unbind();\n }\n\n this.template = template;\n this.createItems();\n\n if (wasBound) {\n this.bind(this.context);\n\n if (wasRendered) {\n const parentNode = this.findParentNode();\n const anchor = this.findNextNode();\n\n if (anchor) {\n const docFrag = createDocumentFragment();\n this.render(docFrag);\n parentNode.insertBefore(docFrag, anchor);\n } else {\n this.render(parentNode);\n }\n }\n }\n }\n\n shuffled() {\n this.items.forEach(shuffled);\n if (this.rootModel) this.rootModel.applyValue(this.context.getKeypath(this.ractive.root));\n if (this.pathModel) this.pathModel.applyValue(this.context.getKeypath());\n }\n\n toString(escape) {\n return this.items.map(escape ? toEscapedString : toString).join('');\n }\n\n unbind() {\n this.context = null;\n this.items.forEach(unbind);\n this.bound = false;\n\n return this;\n }\n\n unrender(shouldDestroy) {\n this.items.forEach(shouldDestroy ? unrenderAndDestroy : unrender);\n this.rendered = false;\n }\n\n update() {\n if (this.dirty) {\n if (!this.updating) {\n this.dirty = false;\n this.updating = true;\n this.items.forEach(update);\n this.updating = false;\n } else if (this.isRoot) {\n runloop.addFragmentToRoot(this);\n }\n }\n }\n\n valueOf() {\n if (this.items.length === 1) {\n return this.items[0].valueOf();\n }\n\n if (this.dirtyValue) {\n const values = {};\n const source = processItems(this.items, values, this.ractive._guid);\n const parsed = parseJSON(source, values);\n\n this.value = parsed ? parsed.value : this.toString();\n\n this.dirtyValue = false;\n }\n\n return this.value;\n }\n}\nFragment.prototype.getContext = getContext;\n","import { TEXT } from 'config/types';\n\n// TODO all this code needs to die\nexport default function processItems(items, values, guid, counter = 0) {\n return items\n .map(item => {\n if (item.type === TEXT) {\n return item.template;\n }\n\n if (item.fragment) {\n if (item.fragment.iterations) {\n return item.fragment.iterations\n .map(fragment => {\n return processItems(fragment.items, values, guid, counter);\n })\n .join('');\n } else {\n return processItems(item.fragment.items, values, guid, counter);\n }\n }\n\n const placeholderId = `${guid}-${counter++}`;\n const model = item.model || item.newModel;\n\n values[placeholderId] = model\n ? model.wrapper ? model.wrapperValue : model.get()\n : undefined;\n\n return '${' + placeholderId + '}';\n })\n .join('');\n}\n","import {\n ALIAS,\n ANCHOR,\n AWAIT,\n COMMENT,\n COMPONENT,\n DOCTYPE,\n ELEMENT,\n INTERPOLATOR,\n PARTIAL,\n SECTION,\n TRIPLE,\n YIELDER\n} from 'config/types';\nimport { ATTRIBUTE, BINDING_FLAG, DECORATOR, EVENT, TRANSITION } from 'config/types';\nimport Alias from './Alias';\nimport Attribute from './element/Attribute';\nimport BindingFlag from './element/BindingFlag';\nimport Comment from './Comment';\nimport Component from './Component';\nimport Decorator from './element/Decorator';\nimport Doctype from './Doctype';\nimport Form from './element/specials/Form';\nimport Element from './Element';\nimport EventDirective from './shared/EventDirective';\nimport Interpolator from './Interpolator';\nimport Input from './element/specials/Input';\nimport Mapping from './component/Mapping';\nimport Option from './element/specials/Option';\nimport Partial from './Partial';\nimport Section from './Section';\nimport Select from './element/specials/Select';\nimport Textarea from './element/specials/Textarea';\nimport Text from './Text';\nimport Transition from './element/Transition';\nimport Triple from './Triple';\nimport getComponentConstructor from './component/getComponentConstructor';\nimport findElement from './shared/findElement';\nimport { findInstance } from 'shared/registry';\nimport asyncProxy from './asyncProxy';\nimport Await from './Await';\nimport { isString, isFunction } from 'utils/is';\n\nconst constructors = {};\nconstructors[ALIAS] = Alias;\nconstructors[ANCHOR] = Component;\nconstructors[AWAIT] = Await;\nconstructors[DOCTYPE] = Doctype;\nconstructors[INTERPOLATOR] = Interpolator;\nconstructors[PARTIAL] = Partial;\nconstructors[SECTION] = Section;\nconstructors[TRIPLE] = Triple;\nconstructors[YIELDER] = Partial;\n\nconstructors[ATTRIBUTE] = Attribute;\nconstructors[BINDING_FLAG] = BindingFlag;\nconstructors[DECORATOR] = Decorator;\nconstructors[EVENT] = EventDirective;\nconstructors[TRANSITION] = Transition;\nconstructors[COMMENT] = Comment;\n\nconst specialElements = {\n doctype: Doctype,\n form: Form,\n input: Input,\n option: Option,\n select: Select,\n textarea: Textarea\n};\n\nexport default function createItem(options) {\n if (isString(options.template)) {\n return new Text(options);\n }\n\n let ctor;\n let name;\n const type = options.template.t;\n\n if (type === ELEMENT) {\n name = options.template.e;\n\n // could be a macro partial\n ctor = findInstance('partials', options.up.ractive, name);\n if (ctor) {\n ctor = ctor.partials[name];\n if (ctor.styleSet) {\n options.macro = ctor;\n return new Partial(options);\n }\n }\n\n // could be component or element\n ctor = getComponentConstructor(options.up.ractive, name);\n if (ctor) {\n if (isFunction(ctor.then)) {\n return asyncProxy(ctor, options);\n } else {\n return new Component(options, ctor);\n }\n }\n\n ctor = specialElements[name.toLowerCase()] || Element;\n return new ctor(options);\n }\n\n let Item;\n\n // component mappings are a special case of attribute\n if (type === ATTRIBUTE) {\n let el = options.owner;\n if (!el || (el.type !== ANCHOR && el.type !== COMPONENT && el.type !== ELEMENT)) {\n el = findElement(options.up);\n }\n options.element = el;\n\n Item = el.type === COMPONENT || el.type === ANCHOR ? Mapping : Attribute;\n } else {\n Item = constructors[type];\n }\n\n if (!Item) throw new Error(`Unrecognised item type ${type}`);\n\n return new Item(options);\n}\n","import { ATTRIBUTE, CATCH, ELEMENT, ELSE, INTERPOLATOR, SECTION, THEN } from 'src/config/types';\nimport Partial from './Partial';\nimport { assign } from 'utils/object';\nimport { isFunction } from 'utils/is';\n\nfunction extract(tpl, type, name) {\n const p = tpl.f.find(s => s.t === type);\n if (p) {\n if (p.n)\n return [\n {\n t: 19,\n n: 54,\n f: p.f || [],\n z: [{ n: p.n, x: { r: `__await.${name}` } }]\n }\n ];\n else return p.f || [];\n } else return [];\n}\n\nexport default function Await(options) {\n const tpl = options.template;\n\n const success = extract(tpl, THEN, 'value');\n const error = extract(tpl, CATCH, 'error');\n const pending = extract(tpl, SECTION);\n const undef = extract(tpl, ELSE);\n\n const opts = assign({}, options, {\n template: {\n t: ELEMENT,\n m: [\n {\n t: ATTRIBUTE,\n n: 'for',\n f: [{ t: INTERPOLATOR, r: tpl.r, rx: tpl.rx, x: tpl.x }]\n }\n ]\n },\n macro(handle, attrs) {\n handle.aliasLocal('__await');\n\n function update(attrs) {\n if (attrs.for && isFunction(attrs.for.then)) {\n handle.setTemplate(pending);\n\n attrs.for.then(\n v => {\n handle.set('@local.value', v);\n handle.setTemplate(success);\n },\n e => {\n handle.set('@local.error', e);\n handle.setTemplate(error);\n }\n );\n } else if (attrs.for === undefined) {\n handle.setTemplate(undef);\n } else {\n handle.set('@local.value', attrs.for);\n handle.setTemplate(success);\n }\n }\n\n update(attrs);\n\n return {\n update\n };\n }\n });\n\n opts.macro.attributes = ['for'];\n\n return new Partial(opts);\n}\n","import Partial from './Partial';\nimport { ELEMENT } from 'config/types';\nimport { assign } from 'utils/object';\n\nexport default function asyncProxy(promise, options) {\n const partials = options.template.p || {};\n const name = options.template.e;\n\n const opts = assign({}, options, {\n template: { t: ELEMENT, e: name },\n macro(handle) {\n handle.setTemplate(partials['async-loading'] || []);\n promise.then(\n cmp => {\n options.up.ractive.components[name] = cmp;\n if (partials['async-loaded']) {\n handle.partials.component = [options.template];\n handle.setTemplate(partials['async-loaded']);\n } else {\n handle.setTemplate([options.template]);\n }\n },\n err => {\n if (partials['async-failed']) {\n handle.aliasLocal('error', 'error');\n handle.set('@local.error', err);\n handle.setTemplate(partials['async-failed']);\n } else {\n handle.setTemplate([]);\n }\n }\n );\n }\n });\n return new Partial(opts);\n}\n","import { noRegistryFunctionReturn } from 'config/errors';\nimport { warnIfDebug } from 'utils/log';\nimport { findInstance } from 'shared/registry';\nimport { hasOwn } from 'utils/object';\nimport { isString } from 'utils/is';\n\n// finds the component constructor in the registry or view hierarchy registries\nexport default function getComponentConstructor(ractive, name) {\n const instance = findInstance('components', ractive, name);\n let Component;\n\n if (instance) {\n Component = instance.components[name];\n\n // if not from Ractive.extend or a Promise, it's a function that shold return a constructor\n if (Component && !Component.isInstance && !Component.then) {\n // function option, execute and store for reset\n const fn = Component.bind(instance);\n fn.isOwner = hasOwn(instance.components, name);\n Component = fn();\n\n if (!Component) {\n warnIfDebug(noRegistryFunctionReturn, name, 'component', 'component', {\n ractive\n });\n return;\n }\n\n if (isString(Component)) {\n // allow string lookup\n Component = getComponentConstructor(ractive, Component);\n }\n\n Component._fn = fn;\n instance.components[name] = Component;\n }\n }\n\n return Component;\n}\n","import { createDocumentFragment, matches } from 'utils/dom';\nimport { detachNode } from 'utils/dom';\nimport { decodeCharacterReferences } from 'utils/html';\nimport runloop from 'src/global/runloop';\nimport Mustache from './shared/Mustache';\nimport insertHtml from './triple/insertHtml';\nimport { inAttribute } from './element/Attribute';\n\nexport default class Triple extends Mustache {\n constructor(options) {\n super(options);\n }\n\n detach() {\n const docFrag = createDocumentFragment();\n if (this.nodes) this.nodes.forEach(node => docFrag.appendChild(node));\n return docFrag;\n }\n\n find(selector) {\n const len = this.nodes.length;\n let i;\n\n for (i = 0; i < len; i += 1) {\n const node = this.nodes[i];\n\n if (node.nodeType !== 1) continue;\n\n if (matches(node, selector)) return node;\n\n const queryResult = node.querySelector(selector);\n if (queryResult) return queryResult;\n }\n\n return null;\n }\n\n findAll(selector, options) {\n const { result } = options;\n const len = this.nodes.length;\n let i;\n\n for (i = 0; i < len; i += 1) {\n const node = this.nodes[i];\n\n if (node.nodeType !== 1) continue;\n\n if (matches(node, selector)) result.push(node);\n\n const queryAllResult = node.querySelectorAll(selector);\n if (queryAllResult) {\n result.push.apply(result, queryAllResult);\n }\n }\n }\n\n findComponent() {\n return null;\n }\n\n firstNode() {\n return this.rendered && this.nodes[0];\n }\n\n render(target, occupants, anchor) {\n if (!this.nodes) {\n const html = this.model ? this.model.get() : '';\n this.nodes = insertHtml(html, target);\n }\n\n let nodes = this.nodes;\n\n // progressive enhancement\n if (occupants) {\n let i = -1;\n let next;\n\n // start with the first node that should be rendered\n while (occupants.length && (next = this.nodes[i + 1])) {\n let n;\n // look through the occupants until a matching node is found\n while ((n = occupants.shift())) {\n const t = n.nodeType;\n\n if (\n t === next.nodeType &&\n ((t === 1 && n.outerHTML === next.outerHTML) ||\n ((t === 3 || t === 8) && n.nodeValue === next.nodeValue))\n ) {\n this.nodes.splice(++i, 1, n); // replace the generated node with the existing one\n break;\n } else {\n target.removeChild(n); // remove the non-matching existing node\n }\n }\n }\n\n if (i >= 0) {\n // update the list of remaining nodes to attach, excluding any that were replaced by existing nodes\n nodes = this.nodes.slice(i);\n }\n\n // update the anchor to be the next occupant\n if (occupants.length) anchor = occupants[0];\n }\n\n // attach any remainging nodes to the parent\n if (nodes.length) {\n const frag = createDocumentFragment();\n nodes.forEach(n => frag.appendChild(n));\n\n if (anchor) {\n target.insertBefore(frag, anchor);\n } else {\n target.appendChild(frag);\n }\n }\n\n this.rendered = true;\n }\n\n toString() {\n let value = this.model && this.model.get();\n value = value != null ? '' + value : '';\n\n return inAttribute() ? decodeCharacterReferences(value) : value;\n }\n\n unrender() {\n if (this.nodes)\n this.nodes.forEach(node => {\n // defer detachment until all relevant outros are done\n runloop.detachWhenReady({\n node,\n detach() {\n detachNode(node);\n }\n });\n });\n this.rendered = false;\n this.nodes = null;\n }\n\n update() {\n if (this.rendered && this.dirty) {\n this.dirty = false;\n\n this.unrender();\n this.render(this.up.findParentNode(), null, this.up.findNextNode(this));\n } else {\n // make sure to reset the dirty flag even if not rendered\n this.dirty = false;\n }\n }\n}\n","import { svg } from 'config/namespaces';\nimport { createElement } from 'utils/dom';\n\nconst elementCache = {};\n\nlet ieBug;\nlet ieBlacklist;\n\ntry {\n createElement('table').innerHTML = 'foo';\n} catch (/* istanbul ignore next */ err) {\n ieBug = true;\n\n ieBlacklist = {\n TABLE: ['