Skip to content

Commit 3c651b8

Browse files
committed
fix: One weird Webkit issue fix at bindings parser
1 parent 6de15e6 commit 3c651b8

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/parsebindings/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ export default function parseBindings(object, givenNodes, eventOptions) {
8989
// fixes Firefox issue: attributes.length can be changed by processAttribute
9090
const attrs = attributes.length > 1 ? [...attributes] : attributes;
9191
nofn.forEach(attrs, (attribute) => {
92+
// Sometimes Webkit returns an attribute itself when attribute.value is accessed
93+
if (attribute.value && typeof attribute.value.value === 'string') {
94+
attribute = attribute.value; // eslint-disable-line no-param-reassign
95+
}
96+
9297
if (bindingReg.test(attribute.value)) {
9398
processAttribute({
9499
node,

test/spec/bindings/bindings_parser_spec.js

+21
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,27 @@ describe('Bindings parser', () => {
9393
expect(node.value).toEqual(obj.x);
9494
});
9595

96+
it('should bind input value with type=text attribute (bugfix)', () => {
97+
const node = parse('<input type="text" value="{{x}}">');
98+
const obj = {};
99+
100+
parseBindings(obj, node, noDebounceFlag);
101+
obj.x = 'foo';
102+
expect(node.value).toEqual(obj.x);
103+
});
104+
105+
it('should bind select value (bugfix)', () => {
106+
const node = parse(`<select value="{{x}}">
107+
<option selected value="bar">bar</option>
108+
<option value="foo">foo</option>
109+
</select>`);
110+
const obj = {};
111+
112+
parseBindings(obj, node, noDebounceFlag);
113+
obj.x = 'foo';
114+
expect(node.value).toEqual(obj.x);
115+
});
116+
96117
it('should bind complex input value', () => {
97118
const node = parse('<input value="{{x}} {{y}}">');
98119
const obj = {};

0 commit comments

Comments
 (0)