add '=' if attribute value is missing

This commit is contained in:
Dennis Ushakov
2015-12-29 15:15:58 +03:00
parent b916981e59
commit f278aaa372
2 changed files with 15 additions and 0 deletions
@@ -1017,4 +1017,18 @@ public class XmlTagTest extends LightCodeInsightTestCase {
}
});
}
public void testSetAttributeValue() {
XmlFile file = (XmlFile)PsiFileFactory.getInstance(getProject()).createFileFromText("dummy.xml", XmlFileType.INSTANCE, "<fooBarGoo attr>1</fooBarGoo>", 0, true);
final XmlTag tag = file.getDocument().getRootTag();
final Document document = file.getViewProvider().getDocument();
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
tag.setAttribute("attr", "");
assertEquals("<fooBarGoo attr=\"\">1</fooBarGoo>", tag.getText());
assertEquals("<fooBarGoo attr=\"\">1</fooBarGoo>", document.getText());
}
});
}
}
@@ -104,6 +104,7 @@ public class XmlAttributeImpl extends XmlElementImpl implements XmlAttribute, Hi
}
else {
if (newValue != null) {
att.addChild(newValue.getTreePrev().copyElement());
att.addChild(newValue.copyElement());
}
}