Skip to content

Commit

Permalink
feat(parseBindings): Slice attributes instead of spread
Browse files Browse the repository at this point in the history
  • Loading branch information
finom committed Dec 8, 2016
1 parent 1e78822 commit 433f108
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/parsebindings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@ export default function parseBindings(object, givenNodes, eventOptions) {
// initialize bindings for attributes if they appear
if (attributes.length) {
// fixes Firefox issue: attributes.length can be changed by processAttribute
const attrs = attributes.length > 1 ? [...attributes] : attributes;
nofn.forEach(attrs, (attribute) => {
// Sometimes Webkit returns an attribute itself when attribute.value is accessed
if (attribute.value && typeof attribute.value.value === 'string') {
attribute = attribute.value; // eslint-disable-line no-param-reassign
}
const attrs = attributes.length > 1
? Array.prototype.slice.call(attributes)
: attributes;

nofn.forEach(attrs, (attribute) => {
if (bindingReg.test(attribute.value)) {
processAttribute({
node,
Expand Down
9 changes: 9 additions & 0 deletions test/spec/bindings/bindings_parser_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,15 @@ describe('Bindings parser', () => {
expect(node.checked).toEqual(obj.x);
});

it('should bind input=checkbox is not checked (bugfix)', () => {
const node = parse('<input type="checkbox" checked="{{x}}">');
const obj = {};

parseBindings(obj, node, noDebounceFlag);
obj.x = false;
expect(node.checked).toEqual(obj.x);
});


it('should bind textarea value', () => {
const node = parse('<textarea value="{{x}}"></textarea>');
Expand Down

0 comments on commit 433f108

Please sign in to comment.