Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Test and fix for #2464 #2465

Merged
merged 2 commits into from
Jan 4, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/language/HTMLUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ define(function (require, exports, module) {

while (TokenUtils.moveNextToken(forwardCtx) && forwardCtx.token.className !== "tag") {
if (forwardCtx.token.className === "attribute") {
// If the current tag is not closed, codemirror may return the next opening
// tag as an attribute. Stop the search loop in that case.
if (forwardCtx.token.string.indexOf("<") === 0) {
break;
}
attrs.push(forwardCtx.token.string);
} else if (forwardCtx.token.className === "error") {
// If we type the first letter of the next attribute, it comes as an error
Expand Down
10 changes: 10 additions & 0 deletions test/spec/CodeHintUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,16 @@ define(function (require, exports, module) {
var attrs = HTMLUtils.getTagAttributes(myEditor, pos);
expect(attrs.sort()).toEqual(["id", "class", "lang", "align", "title"].sort());
});

it("should not find attributes of other tags on an opened tag", function () {
var pos = {"ch": 0, "line": 0};
setContentAndUpdatePos(pos,
["<html>", "<body>"],
"<div ", "",
["<div id='foo' class='clazz'>", "</div>", "</body>", "</html>"]);
var attrs = HTMLUtils.getTagAttributes(myEditor, pos);
expect(attrs).toEqual([]);
});
});
});
});