diff --git a/bower.json b/bower.json index 369ad240..9c5feddd 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "aurelia-binding", - "version": "1.0.4", + "version": "1.0.5", "description": "A modern databinding library for JavaScript and HTML.", "license": "MIT", "keywords": [ diff --git a/dist/amd/aurelia-binding.js b/dist/amd/aurelia-binding.js index 69e46fde..7bb8220b 100644 --- a/dist/amd/aurelia-binding.js +++ b/dist/amd/aurelia-binding.js @@ -1920,21 +1920,12 @@ define(['exports', 'aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aure return LiteralObject; }(Expression); - var evalListCache = [[], [0], [0, 0], [0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0, 0]]; - function evalList(scope, list, lookupFunctions) { var length = list.length; - - for (var cacheLength = evalListCache.length; cacheLength <= length; ++cacheLength) { - evalListCache.push([]); - } - - var result = evalListCache[length]; - - for (var _i14 = 0; _i14 < length; ++_i14) { + var result = []; + for (var _i14 = 0; _i14 < length; _i14++) { result[_i14] = list[_i14].evaluate(scope, lookupFunctions); } - return result; } @@ -3017,7 +3008,7 @@ define(['exports', 'aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aure if (this.optional('.')) { name = this.peek.key; this.advance(); - } else if (this.peek === EOF || this.peek.text === '(' || this.peek.text === '[' || this.peek.text === '}') { + } else if (this.peek === EOF || this.peek.text === '(' || this.peek.text === '[' || this.peek.text === '}' || this.peek.text === ',') { return new AccessThis(ancestor); } else { this.error('Unexpected token ' + this.peek.text); @@ -3698,6 +3689,16 @@ define(['exports', 'aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aure return this.element.style.cssText; }; + StyleObserver.prototype._setProperty = function _setProperty(style, value) { + var priority = ''; + + if (value.indexOf('!important') !== -1) { + priority = 'important'; + value = value.replace('!important', ''); + } + this.element.style.setProperty(style, value, priority); + }; + StyleObserver.prototype.setValue = function setValue(newValue) { var styles = this.styles || {}; var style = void 0; @@ -3708,7 +3709,7 @@ define(['exports', 'aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aure for (style in newValue) { if (newValue.hasOwnProperty(style)) { styles[style] = version; - this.element.style[style] = newValue[style]; + this._setProperty(style, newValue[style]); } } } else if (newValue.length) { @@ -3721,7 +3722,7 @@ define(['exports', 'aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aure } styles[style] = version; - this.element.style[style] = pair[2]; + this._setProperty(style, pair[2]); } } } @@ -3739,7 +3740,7 @@ define(['exports', 'aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aure continue; } - this.element.style[style] = ''; + this.element.style.removeProperty(style); } }; @@ -4601,7 +4602,7 @@ define(['exports', 'aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aure if (xlinkResult) { return new XLinkAttributeObserver(obj, propertyName, xlinkResult[1]); } - if (/^\w+:|^data-|^aria-/.test(propertyName) || obj instanceof _aureliaPal.DOM.SVGElement && this.svgAnalyzer.isStandardSvgAttribute(obj.nodeName, propertyName)) { + if (propertyName === 'role' && (obj instanceof _aureliaPal.DOM.Element || obj instanceof _aureliaPal.DOM.SVGElement) || /^\w+:|^data-|^aria-/.test(propertyName) || obj instanceof _aureliaPal.DOM.SVGElement && this.svgAnalyzer.isStandardSvgAttribute(obj.nodeName, propertyName)) { return new DataAttributeObserver(obj, propertyName); } } @@ -5304,7 +5305,8 @@ define(['exports', 'aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aure function observable(targetOrConfig, key, descriptor) { function deco(target, key, descriptor, config) { - if (key === undefined) { + var isClassDecorator = key === undefined; + if (isClassDecorator) { target = target.prototype; key = typeof config === 'string' ? config : config.name; } @@ -5321,6 +5323,10 @@ define(['exports', 'aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aure descriptor = {}; } + if (!('enumerable' in descriptor)) { + descriptor.enumerable = true; + } + delete descriptor.writable; delete descriptor.initializer; @@ -5337,7 +5343,11 @@ define(['exports', 'aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aure descriptor.get.dependencies = [innerPropertyName]; - Reflect.defineProperty(target, key, descriptor); + if (isClassDecorator) { + Reflect.defineProperty(target, key, descriptor); + } else { + return descriptor; + } } if (key === undefined) { diff --git a/dist/aurelia-binding.d.ts b/dist/aurelia-binding.d.ts index 958aa66b..e87a22dd 100644 --- a/dist/aurelia-binding.d.ts +++ b/dist/aurelia-binding.d.ts @@ -184,6 +184,11 @@ export declare interface InternalPropertyObserver { unsubscribe(context: any, callable: Callable): void; } +/** + * Property observer for HTML Attributes. + */ +export declare class DataAttributeObserver implements InternalPropertyObserver {} + /** * Observes collection mutation. */ diff --git a/dist/aurelia-binding.js b/dist/aurelia-binding.js index c4b2177a..994a717d 100644 --- a/dist/aurelia-binding.js +++ b/dist/aurelia-binding.js @@ -1769,22 +1769,13 @@ export class LiteralObject extends Expression { } } -let evalListCache = [[], [0], [0, 0], [0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0, 0]]; - /// Evaluate the [list] in context of the [scope]. function evalList(scope, list, lookupFunctions) { - let length = list.length; - - for (let cacheLength = evalListCache.length; cacheLength <= length; ++cacheLength) { - evalListCache.push([]); - } - - let result = evalListCache[length]; - - for (let i = 0; i < length; ++i) { + const length = list.length; + const result = []; + for (let i = 0; i < length; i++) { result[i] = list[i].evaluate(scope, lookupFunctions); } - return result; } @@ -2889,7 +2880,12 @@ export class ParserImplementation { if (this.optional('.')) { name = this.peek.key; this.advance(); - } else if (this.peek === EOF || this.peek.text === '(' || this.peek.text === '[' || this.peek.text === '}') { + } else if (this.peek === EOF + || this.peek.text === '(' + || this.peek.text === '[' + || this.peek.text === '}' + || this.peek.text === ',' + ) { return new AccessThis(ancestor); } else { this.error(`Unexpected token ${this.peek.text}`); @@ -3512,6 +3508,16 @@ export class StyleObserver { return this.element.style.cssText; } + _setProperty(style, value) { + let priority = ''; + + if (value.indexOf('!important') !== -1) { + priority = 'important'; + value = value.replace('!important', ''); + } + this.element.style.setProperty(style, value, priority); + } + setValue(newValue) { let styles = this.styles || {}; let style; @@ -3522,7 +3528,7 @@ export class StyleObserver { for (style in newValue) { if (newValue.hasOwnProperty(style)) { styles[style] = version; - this.element.style[style] = newValue[style]; + this._setProperty(style, newValue[style]); } } } else if (newValue.length) { @@ -3533,7 +3539,7 @@ export class StyleObserver { if ( !style ) { continue; } styles[style] = version; - this.element.style[style] = pair[2]; + this._setProperty(style, pair[2]); } } } @@ -3551,7 +3557,7 @@ export class StyleObserver { continue; } - this.element.style[style] = ''; + this.element.style.removeProperty(style); } } @@ -4357,7 +4363,8 @@ export class ObserverLocator { if (xlinkResult) { return new XLinkAttributeObserver(obj, propertyName, xlinkResult[1]); } - if (/^\w+:|^data-|^aria-/.test(propertyName) + if (propertyName === 'role' && (obj instanceof DOM.Element || obj instanceof DOM.SVGElement) + || /^\w+:|^data-|^aria-/.test(propertyName) || obj instanceof DOM.SVGElement && this.svgAnalyzer.isStandardSvgAttribute(obj.nodeName, propertyName)) { return new DataAttributeObserver(obj, propertyName); } @@ -5025,7 +5032,8 @@ class ModifySetObserver extends ModifyCollectionObserver { export function observable(targetOrConfig: any, key: string, descriptor?: PropertyDescriptor) { function deco(target, key, descriptor, config) { // eslint-disable-line no-shadow // class decorator? - if (key === undefined) { + const isClassDecorator = key === undefined; + if (isClassDecorator) { target = target.prototype; key = typeof config === 'string' ? config : config.name; } @@ -5044,8 +5052,14 @@ export function observable(targetOrConfig: any, key: string, descriptor?: Proper target[innerPropertyName] = descriptor.initializer(); } } else { + // there is no descriptor if the target was a field in TS (although Babel provides one), + // or if the decorator was applied to a class. descriptor = {}; } + // make the accessor enumerable by default, as fields are enumerable + if (!('enumerable' in descriptor)) { + descriptor.enumerable = true; + } // we're adding a getter and setter which means the property descriptor // cannot have a "value" or "writable" attribute @@ -5066,7 +5080,11 @@ export function observable(targetOrConfig: any, key: string, descriptor?: Proper // dependencies. This is the equivalent of "@computedFrom(...)". descriptor.get.dependencies = [innerPropertyName]; - Reflect.defineProperty(target, key, descriptor); + if (isClassDecorator) { + Reflect.defineProperty(target, key, descriptor); + } else { + return descriptor; + } } if (key === undefined) { diff --git a/dist/commonjs/aurelia-binding.js b/dist/commonjs/aurelia-binding.js index 13c36a93..c000d7e3 100644 --- a/dist/commonjs/aurelia-binding.js +++ b/dist/commonjs/aurelia-binding.js @@ -1873,21 +1873,12 @@ var LiteralObject = exports.LiteralObject = function (_Expression18) { return LiteralObject; }(Expression); -var evalListCache = [[], [0], [0, 0], [0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0, 0]]; - function evalList(scope, list, lookupFunctions) { var length = list.length; - - for (var cacheLength = evalListCache.length; cacheLength <= length; ++cacheLength) { - evalListCache.push([]); - } - - var result = evalListCache[length]; - - for (var _i14 = 0; _i14 < length; ++_i14) { + var result = []; + for (var _i14 = 0; _i14 < length; _i14++) { result[_i14] = list[_i14].evaluate(scope, lookupFunctions); } - return result; } @@ -2970,7 +2961,7 @@ var ParserImplementation = exports.ParserImplementation = function () { if (this.optional('.')) { name = this.peek.key; this.advance(); - } else if (this.peek === EOF || this.peek.text === '(' || this.peek.text === '[' || this.peek.text === '}') { + } else if (this.peek === EOF || this.peek.text === '(' || this.peek.text === '[' || this.peek.text === '}' || this.peek.text === ',') { return new AccessThis(ancestor); } else { this.error('Unexpected token ' + this.peek.text); @@ -3651,6 +3642,16 @@ var StyleObserver = exports.StyleObserver = function () { return this.element.style.cssText; }; + StyleObserver.prototype._setProperty = function _setProperty(style, value) { + var priority = ''; + + if (value.indexOf('!important') !== -1) { + priority = 'important'; + value = value.replace('!important', ''); + } + this.element.style.setProperty(style, value, priority); + }; + StyleObserver.prototype.setValue = function setValue(newValue) { var styles = this.styles || {}; var style = void 0; @@ -3661,7 +3662,7 @@ var StyleObserver = exports.StyleObserver = function () { for (style in newValue) { if (newValue.hasOwnProperty(style)) { styles[style] = version; - this.element.style[style] = newValue[style]; + this._setProperty(style, newValue[style]); } } } else if (newValue.length) { @@ -3674,7 +3675,7 @@ var StyleObserver = exports.StyleObserver = function () { } styles[style] = version; - this.element.style[style] = pair[2]; + this._setProperty(style, pair[2]); } } } @@ -3692,7 +3693,7 @@ var StyleObserver = exports.StyleObserver = function () { continue; } - this.element.style[style] = ''; + this.element.style.removeProperty(style); } }; @@ -4554,7 +4555,7 @@ var ObserverLocator = exports.ObserverLocator = (_temp = _class11 = function () if (xlinkResult) { return new XLinkAttributeObserver(obj, propertyName, xlinkResult[1]); } - if (/^\w+:|^data-|^aria-/.test(propertyName) || obj instanceof _aureliaPal.DOM.SVGElement && this.svgAnalyzer.isStandardSvgAttribute(obj.nodeName, propertyName)) { + if (propertyName === 'role' && (obj instanceof _aureliaPal.DOM.Element || obj instanceof _aureliaPal.DOM.SVGElement) || /^\w+:|^data-|^aria-/.test(propertyName) || obj instanceof _aureliaPal.DOM.SVGElement && this.svgAnalyzer.isStandardSvgAttribute(obj.nodeName, propertyName)) { return new DataAttributeObserver(obj, propertyName); } } @@ -5257,7 +5258,8 @@ var ModifySetObserver = function (_ModifyCollectionObse3) { function observable(targetOrConfig, key, descriptor) { function deco(target, key, descriptor, config) { - if (key === undefined) { + var isClassDecorator = key === undefined; + if (isClassDecorator) { target = target.prototype; key = typeof config === 'string' ? config : config.name; } @@ -5274,6 +5276,10 @@ function observable(targetOrConfig, key, descriptor) { descriptor = {}; } + if (!('enumerable' in descriptor)) { + descriptor.enumerable = true; + } + delete descriptor.writable; delete descriptor.initializer; @@ -5290,7 +5296,11 @@ function observable(targetOrConfig, key, descriptor) { descriptor.get.dependencies = [innerPropertyName]; - Reflect.defineProperty(target, key, descriptor); + if (isClassDecorator) { + Reflect.defineProperty(target, key, descriptor); + } else { + return descriptor; + } } if (key === undefined) { diff --git a/dist/es2015/aurelia-binding.js b/dist/es2015/aurelia-binding.js index da629c38..8a827da3 100644 --- a/dist/es2015/aurelia-binding.js +++ b/dist/es2015/aurelia-binding.js @@ -1675,21 +1675,12 @@ export let LiteralObject = class LiteralObject extends Expression { } }; -let evalListCache = [[], [0], [0, 0], [0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0, 0]]; - function evalList(scope, list, lookupFunctions) { - let length = list.length; - - for (let cacheLength = evalListCache.length; cacheLength <= length; ++cacheLength) { - evalListCache.push([]); - } - - let result = evalListCache[length]; - - for (let i = 0; i < length; ++i) { + const length = list.length; + const result = []; + for (let i = 0; i < length; i++) { result[i] = list[i].evaluate(scope, lookupFunctions); } - return result; } @@ -2744,7 +2735,7 @@ export let ParserImplementation = class ParserImplementation { if (this.optional('.')) { name = this.peek.key; this.advance(); - } else if (this.peek === EOF || this.peek.text === '(' || this.peek.text === '[' || this.peek.text === '}') { + } else if (this.peek === EOF || this.peek.text === '(' || this.peek.text === '[' || this.peek.text === '}' || this.peek.text === ',') { return new AccessThis(ancestor); } else { this.error(`Unexpected token ${ this.peek.text }`); @@ -3352,6 +3343,16 @@ export let StyleObserver = class StyleObserver { return this.element.style.cssText; } + _setProperty(style, value) { + let priority = ''; + + if (value.indexOf('!important') !== -1) { + priority = 'important'; + value = value.replace('!important', ''); + } + this.element.style.setProperty(style, value, priority); + } + setValue(newValue) { let styles = this.styles || {}; let style; @@ -3362,7 +3363,7 @@ export let StyleObserver = class StyleObserver { for (style in newValue) { if (newValue.hasOwnProperty(style)) { styles[style] = version; - this.element.style[style] = newValue[style]; + this._setProperty(style, newValue[style]); } } } else if (newValue.length) { @@ -3375,7 +3376,7 @@ export let StyleObserver = class StyleObserver { } styles[style] = version; - this.element.style[style] = pair[2]; + this._setProperty(style, pair[2]); } } } @@ -3393,7 +3394,7 @@ export let StyleObserver = class StyleObserver { continue; } - this.element.style[style] = ''; + this.element.style.removeProperty(style); } } @@ -4176,7 +4177,7 @@ export let ObserverLocator = (_temp = _class11 = class ObserverLocator { if (xlinkResult) { return new XLinkAttributeObserver(obj, propertyName, xlinkResult[1]); } - if (/^\w+:|^data-|^aria-/.test(propertyName) || obj instanceof DOM.SVGElement && this.svgAnalyzer.isStandardSvgAttribute(obj.nodeName, propertyName)) { + if (propertyName === 'role' && (obj instanceof DOM.Element || obj instanceof DOM.SVGElement) || /^\w+:|^data-|^aria-/.test(propertyName) || obj instanceof DOM.SVGElement && this.svgAnalyzer.isStandardSvgAttribute(obj.nodeName, propertyName)) { return new DataAttributeObserver(obj, propertyName); } } @@ -4798,7 +4799,8 @@ let ModifySetObserver = class ModifySetObserver extends ModifyCollectionObserver export function observable(targetOrConfig, key, descriptor) { function deco(target, key, descriptor, config) { - if (key === undefined) { + const isClassDecorator = key === undefined; + if (isClassDecorator) { target = target.prototype; key = typeof config === 'string' ? config : config.name; } @@ -4815,6 +4817,10 @@ export function observable(targetOrConfig, key, descriptor) { descriptor = {}; } + if (!('enumerable' in descriptor)) { + descriptor.enumerable = true; + } + delete descriptor.writable; delete descriptor.initializer; @@ -4831,7 +4837,11 @@ export function observable(targetOrConfig, key, descriptor) { descriptor.get.dependencies = [innerPropertyName]; - Reflect.defineProperty(target, key, descriptor); + if (isClassDecorator) { + Reflect.defineProperty(target, key, descriptor); + } else { + return descriptor; + } } if (key === undefined) { diff --git a/dist/native-modules/aurelia-binding.js b/dist/native-modules/aurelia-binding.js index a13984f3..f435e639 100644 --- a/dist/native-modules/aurelia-binding.js +++ b/dist/native-modules/aurelia-binding.js @@ -1841,21 +1841,12 @@ export var LiteralObject = function (_Expression18) { return LiteralObject; }(Expression); -var evalListCache = [[], [0], [0, 0], [0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0, 0]]; - function evalList(scope, list, lookupFunctions) { var length = list.length; - - for (var cacheLength = evalListCache.length; cacheLength <= length; ++cacheLength) { - evalListCache.push([]); - } - - var result = evalListCache[length]; - - for (var _i14 = 0; _i14 < length; ++_i14) { + var result = []; + for (var _i14 = 0; _i14 < length; _i14++) { result[_i14] = list[_i14].evaluate(scope, lookupFunctions); } - return result; } @@ -2938,7 +2929,7 @@ export var ParserImplementation = function () { if (this.optional('.')) { name = this.peek.key; this.advance(); - } else if (this.peek === EOF || this.peek.text === '(' || this.peek.text === '[' || this.peek.text === '}') { + } else if (this.peek === EOF || this.peek.text === '(' || this.peek.text === '[' || this.peek.text === '}' || this.peek.text === ',') { return new AccessThis(ancestor); } else { this.error('Unexpected token ' + this.peek.text); @@ -3616,6 +3607,16 @@ export var StyleObserver = function () { return this.element.style.cssText; }; + StyleObserver.prototype._setProperty = function _setProperty(style, value) { + var priority = ''; + + if (value.indexOf('!important') !== -1) { + priority = 'important'; + value = value.replace('!important', ''); + } + this.element.style.setProperty(style, value, priority); + }; + StyleObserver.prototype.setValue = function setValue(newValue) { var styles = this.styles || {}; var style = void 0; @@ -3626,7 +3627,7 @@ export var StyleObserver = function () { for (style in newValue) { if (newValue.hasOwnProperty(style)) { styles[style] = version; - this.element.style[style] = newValue[style]; + this._setProperty(style, newValue[style]); } } } else if (newValue.length) { @@ -3639,7 +3640,7 @@ export var StyleObserver = function () { } styles[style] = version; - this.element.style[style] = pair[2]; + this._setProperty(style, pair[2]); } } } @@ -3657,7 +3658,7 @@ export var StyleObserver = function () { continue; } - this.element.style[style] = ''; + this.element.style.removeProperty(style); } }; @@ -4519,7 +4520,7 @@ export var ObserverLocator = (_temp = _class11 = function () { if (xlinkResult) { return new XLinkAttributeObserver(obj, propertyName, xlinkResult[1]); } - if (/^\w+:|^data-|^aria-/.test(propertyName) || obj instanceof DOM.SVGElement && this.svgAnalyzer.isStandardSvgAttribute(obj.nodeName, propertyName)) { + if (propertyName === 'role' && (obj instanceof DOM.Element || obj instanceof DOM.SVGElement) || /^\w+:|^data-|^aria-/.test(propertyName) || obj instanceof DOM.SVGElement && this.svgAnalyzer.isStandardSvgAttribute(obj.nodeName, propertyName)) { return new DataAttributeObserver(obj, propertyName); } } @@ -5219,7 +5220,8 @@ var ModifySetObserver = function (_ModifyCollectionObse3) { export function observable(targetOrConfig, key, descriptor) { function deco(target, key, descriptor, config) { - if (key === undefined) { + var isClassDecorator = key === undefined; + if (isClassDecorator) { target = target.prototype; key = typeof config === 'string' ? config : config.name; } @@ -5236,6 +5238,10 @@ export function observable(targetOrConfig, key, descriptor) { descriptor = {}; } + if (!('enumerable' in descriptor)) { + descriptor.enumerable = true; + } + delete descriptor.writable; delete descriptor.initializer; @@ -5252,7 +5258,11 @@ export function observable(targetOrConfig, key, descriptor) { descriptor.get.dependencies = [innerPropertyName]; - Reflect.defineProperty(target, key, descriptor); + if (isClassDecorator) { + Reflect.defineProperty(target, key, descriptor); + } else { + return descriptor; + } } if (key === undefined) { diff --git a/dist/system/aurelia-binding.js b/dist/system/aurelia-binding.js index e92135bb..20060ebc 100644 --- a/dist/system/aurelia-binding.js +++ b/dist/system/aurelia-binding.js @@ -3,7 +3,7 @@ System.register(['aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aurelia-metadata'], function (_export, _context) { "use strict"; - var LogManager, PLATFORM, DOM, TaskQueue, metadata, _typeof, _createClass, _dec, _dec2, _class, _dec3, _class2, _dec4, _class3, _dec5, _class5, _dec6, _class7, _dec7, _class8, _dec8, _class9, _dec9, _class10, _class11, _temp, _dec10, _class12, _class13, _temp2, map, sourceContext, slotNames, versionSlotNames, i, bindings, minimumImmediate, frameBudget, isFlushRequested, immediate, arrayPool1, arrayPool2, poolUtilization, ExpressionObserver, EDIT_LEAVE, EDIT_UPDATE, EDIT_ADD, EDIT_DELETE, arraySplice, ModifyCollectionObserver, CollectionLengthObserver, pop, push, reverse, shift, sort, splice, unshift, ModifyArrayObserver, Expression, Chain, BindingBehavior, ValueConverter, Assign, Conditional, AccessThis, AccessScope, AccessMember, AccessKeyed, CallScope, CallMember, CallFunction, Binary, PrefixNot, LiteralPrimitive, LiteralString, LiteralArray, LiteralObject, evalListCache, Unparser, ExpressionCloner, bindingMode, Token, Lexer, Scanner, OPERATORS, $EOF, $TAB, $LF, $VTAB, $FF, $CR, $SPACE, $BANG, $DQ, $$, $PERCENT, $AMPERSAND, $SQ, $LPAREN, $RPAREN, $STAR, $PLUS, $COMMA, $MINUS, $PERIOD, $SLASH, $COLON, $SEMICOLON, $LT, $EQ, $GT, $QUESTION, $0, $9, $A, $E, $Z, $LBRACKET, $BACKSLASH, $RBRACKET, $CARET, $_, $a, $e, $f, $n, $r, $t, $u, $v, $z, $LBRACE, $BAR, $RBRACE, $NBSP, EOF, Parser, ParserImplementation, mapProto, ModifyMapObserver, DelegateHandlerEntry, DefaultEventStrategy, EventManager, DirtyChecker, DirtyCheckProperty, logger, propertyAccessor, PrimitiveObserver, SetterObserver, XLinkAttributeObserver, dataAttributeAccessor, DataAttributeObserver, StyleObserver, ValueAttributeObserver, checkedArrayContext, checkedValueContext, CheckedObserver, selectArrayContext, SelectValueObserver, ClassObserver, ComputedExpression, elements, presentationElements, presentationAttributes, SVGAnalyzer, ObserverLocator, ObjectObservationAdapter, BindingExpression, targetContext, Binding, CallExpression, Call, ValueConverterResource, BindingBehaviorResource, ListenerExpression, Listener, NameExpression, NameBinder, LookupFunctions, BindingEngine, setProto, ModifySetObserver; + var LogManager, PLATFORM, DOM, TaskQueue, metadata, _typeof, _createClass, _dec, _dec2, _class, _dec3, _class2, _dec4, _class3, _dec5, _class5, _dec6, _class7, _dec7, _class8, _dec8, _class9, _dec9, _class10, _class11, _temp, _dec10, _class12, _class13, _temp2, map, sourceContext, slotNames, versionSlotNames, i, bindings, minimumImmediate, frameBudget, isFlushRequested, immediate, arrayPool1, arrayPool2, poolUtilization, ExpressionObserver, EDIT_LEAVE, EDIT_UPDATE, EDIT_ADD, EDIT_DELETE, arraySplice, ModifyCollectionObserver, CollectionLengthObserver, pop, push, reverse, shift, sort, splice, unshift, ModifyArrayObserver, Expression, Chain, BindingBehavior, ValueConverter, Assign, Conditional, AccessThis, AccessScope, AccessMember, AccessKeyed, CallScope, CallMember, CallFunction, Binary, PrefixNot, LiteralPrimitive, LiteralString, LiteralArray, LiteralObject, Unparser, ExpressionCloner, bindingMode, Token, Lexer, Scanner, OPERATORS, $EOF, $TAB, $LF, $VTAB, $FF, $CR, $SPACE, $BANG, $DQ, $$, $PERCENT, $AMPERSAND, $SQ, $LPAREN, $RPAREN, $STAR, $PLUS, $COMMA, $MINUS, $PERIOD, $SLASH, $COLON, $SEMICOLON, $LT, $EQ, $GT, $QUESTION, $0, $9, $A, $E, $Z, $LBRACKET, $BACKSLASH, $RBRACKET, $CARET, $_, $a, $e, $f, $n, $r, $t, $u, $v, $z, $LBRACE, $BAR, $RBRACE, $NBSP, EOF, Parser, ParserImplementation, mapProto, ModifyMapObserver, DelegateHandlerEntry, DefaultEventStrategy, EventManager, DirtyChecker, DirtyCheckProperty, logger, propertyAccessor, PrimitiveObserver, SetterObserver, XLinkAttributeObserver, dataAttributeAccessor, DataAttributeObserver, StyleObserver, ValueAttributeObserver, checkedArrayContext, checkedValueContext, CheckedObserver, selectArrayContext, SelectValueObserver, ClassObserver, ComputedExpression, elements, presentationElements, presentationAttributes, SVGAnalyzer, ObserverLocator, ObjectObservationAdapter, BindingExpression, targetContext, Binding, CallExpression, Call, ValueConverterResource, BindingBehaviorResource, ListenerExpression, Listener, NameExpression, NameBinder, LookupFunctions, BindingEngine, setProto, ModifySetObserver; function _possibleConstructorReturn(self, call) { if (!self) { @@ -559,17 +559,10 @@ System.register(['aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aureli function evalList(scope, list, lookupFunctions) { var length = list.length; - - for (var cacheLength = evalListCache.length; cacheLength <= length; ++cacheLength) { - evalListCache.push([]); - } - - var result = evalListCache[length]; - - for (var _i14 = 0; _i14 < length; ++_i14) { + var result = []; + for (var _i14 = 0; _i14 < length; _i14++) { result[_i14] = list[_i14].evaluate(scope, lookupFunctions); } - return result; } @@ -815,7 +808,8 @@ System.register(['aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aureli function observable(targetOrConfig, key, descriptor) { function deco(target, key, descriptor, config) { - if (key === undefined) { + var isClassDecorator = key === undefined; + if (isClassDecorator) { target = target.prototype; key = typeof config === 'string' ? config : config.name; } @@ -832,6 +826,10 @@ System.register(['aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aureli descriptor = {}; } + if (!('enumerable' in descriptor)) { + descriptor.enumerable = true; + } + delete descriptor.writable; delete descriptor.initializer; @@ -848,7 +846,11 @@ System.register(['aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aureli descriptor.get.dependencies = [innerPropertyName]; - Reflect.defineProperty(target, key, descriptor); + if (isClassDecorator) { + Reflect.defineProperty(target, key, descriptor); + } else { + return descriptor; + } } if (key === undefined) { @@ -2261,8 +2263,6 @@ System.register(['aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aureli _export('LiteralObject', LiteralObject); - evalListCache = [[], [0], [0, 0], [0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0, 0]]; - _export('Unparser', Unparser = function () { function Unparser(buffer) { @@ -3234,7 +3234,7 @@ System.register(['aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aureli if (this.optional('.')) { name = this.peek.key; this.advance(); - } else if (this.peek === EOF || this.peek.text === '(' || this.peek.text === '[' || this.peek.text === '}') { + } else if (this.peek === EOF || this.peek.text === '(' || this.peek.text === '[' || this.peek.text === '}' || this.peek.text === ',') { return new AccessThis(ancestor); } else { this.error('Unexpected token ' + this.peek.text); @@ -3897,6 +3897,16 @@ System.register(['aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aureli return this.element.style.cssText; }; + StyleObserver.prototype._setProperty = function _setProperty(style, value) { + var priority = ''; + + if (value.indexOf('!important') !== -1) { + priority = 'important'; + value = value.replace('!important', ''); + } + this.element.style.setProperty(style, value, priority); + }; + StyleObserver.prototype.setValue = function setValue(newValue) { var styles = this.styles || {}; var style = void 0; @@ -3907,7 +3917,7 @@ System.register(['aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aureli for (style in newValue) { if (newValue.hasOwnProperty(style)) { styles[style] = version; - this.element.style[style] = newValue[style]; + this._setProperty(style, newValue[style]); } } } else if (newValue.length) { @@ -3920,7 +3930,7 @@ System.register(['aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aureli } styles[style] = version; - this.element.style[style] = pair[2]; + this._setProperty(style, pair[2]); } } } @@ -3938,7 +3948,7 @@ System.register(['aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aureli continue; } - this.element.style[style] = ''; + this.element.style.removeProperty(style); } }; @@ -4779,7 +4789,7 @@ System.register(['aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aureli if (xlinkResult) { return new XLinkAttributeObserver(obj, propertyName, xlinkResult[1]); } - if (/^\w+:|^data-|^aria-/.test(propertyName) || obj instanceof DOM.SVGElement && this.svgAnalyzer.isStandardSvgAttribute(obj.nodeName, propertyName)) { + if (propertyName === 'role' && (obj instanceof DOM.Element || obj instanceof DOM.SVGElement) || /^\w+:|^data-|^aria-/.test(propertyName) || obj instanceof DOM.SVGElement && this.svgAnalyzer.isStandardSvgAttribute(obj.nodeName, propertyName)) { return new DataAttributeObserver(obj, propertyName); } } diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index e3dd4da1..b5aaf636 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -1,3 +1,17 @@ + +## [1.0.5](https://github.com/aurelia/binding/compare/1.0.4...v1.0.5) (2016-09-29) + + +### Bug Fixes + +* **AST:** remove evalList array cache ([73f1a3e](https://github.com/aurelia/binding/commit/73f1a3e)), closes [#495](https://github.com/aurelia/binding/issues/495) +* **observable:** enable chaining, enumerating ([6586cd2](https://github.com/aurelia/binding/commit/6586cd2)), closes [#501](https://github.com/aurelia/binding/issues/501) +* **ObserverLocator:** use correct observer for aria role ([ca1dd60](https://github.com/aurelia/binding/commit/ca1dd60)), closes [aurelia/framework#582](https://github.com/aurelia/framework/issues/582) [#486](https://github.com/aurelia/binding/issues/486) +* **Parser:** fix object literal parsing with ([52d01dd](https://github.com/aurelia/binding/commit/52d01dd)), closes [#502](https://github.com/aurelia/binding/issues/502) +* **StyleObserver:** enable !important override ([0872d12](https://github.com/aurelia/binding/commit/0872d12)), closes [aurelia/templating-resources#251](https://github.com/aurelia/templating-resources/issues/251) + + + ## [1.0.4](https://github.com/aurelia/binding/compare/1.0.3...v1.0.4) (2016-09-07) diff --git a/package.json b/package.json index 9b7de291..43556f2d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurelia-binding", - "version": "1.0.4", + "version": "1.0.5", "description": "A modern databinding library for JavaScript and HTML.", "keywords": [ "aurelia",