Skip to content

Commit

Permalink
fix: fix select auto fill bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Huang committed Feb 10, 2020
1 parent 756b4a7 commit 3acdad7
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions render.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,16 @@ export const Render = {

for (let i = 0; i < elementsWithAttribute.length; i++) {
const element = elementsWithAttribute[i];
if (element.tagName.toLowerCase() === 'select') {
Render.registElementToVariable(variableObj, propertyName, element, 'select');
element.value = variableObj[propertyName];
}

let attrNames = element.getAttributeNames();
for (let j = 0; j < attrNames.length; j++) {
const attrName = attrNames[j];
const attrValue = element.getAttribute(attrName);

if (element.tagName.toLowerCase() === 'select' && attrName === 'value' && attrValue.indexOf(`{${propertyName}}`) !== -1) {
Render.registElementToVariable(variableObj, propertyName, element, 'select');
element.value = variableObj[propertyName];
}

if (attrName === `{${propertyName.toLowerCase()}}`) {
Render.registElementToVariable(variableObj, propertyName, element, 'no-value-attribute', attrName);
element.removeAttribute(attrName);
Expand Down Expand Up @@ -350,7 +350,7 @@ export const Render = {
}
}

const testVariable = Object.defineProperty(variableObj, propertyName, {
const registResult = Object.defineProperty(variableObj, propertyName, {
// refactor: debounce set
set: function (newValue) {
const bindingElements = Render._getBindingElements(variableObj, propertyName);
Expand Down Expand Up @@ -388,13 +388,13 @@ export const Render = {
return variableObj[`_${propertyName}`];
}
});
if (!window.test) {
window.test = [];
if (!window.SwimAppRegisterElements) {
window.SwimAppRegisterElements = [];
}
window.test.push({
window.SwimAppRegisterElements.push({
className: elRoot.className,
propertyName,
ref: testVariable
ref: registResult
});
}
},
Expand Down

0 comments on commit 3acdad7

Please sign in to comment.