-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Added Code to HtmlUtils to return info when in closing tag #3419
Changes from 4 commits
391342c
a079da6
b507ad0
f50e376
53cbe28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ define(function (require, exports, module) { | |
|
||
//constants | ||
var TAG_NAME = "tagName", | ||
CLOSING_TAG = "closingTag", | ||
ATTR_NAME = "attr.name", | ||
ATTR_VALUE = "attr.value"; | ||
|
||
|
@@ -399,12 +400,16 @@ define(function (require, exports, module) { | |
return createTagInfo(); | ||
} | ||
|
||
// Check to see if this is the closing of a tag (either the start or end) | ||
if (ctx.token.string === ">" || ctx.token.string === "/>" || | ||
(ctx.token.string.charAt(0) === "<" && ctx.token.string.charAt(1) === "/")) { | ||
// Check to see if this is the closing of a tag (either the start or end) self closing tag | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also update this comment to " the closing of a start tag or self closing tag." |
||
if (ctx.token.string === ">" || ctx.token.string === "/>") { | ||
return createTagInfo(); | ||
} | ||
|
||
// Check to see if this is the closing of a tag (either the start or end) closing tag | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I should have caught this in the previous round of review. This comment is no longer correct. We're just handling closing tag here. |
||
if (ctx.token.string.charAt(0) === "<" && ctx.token.string.charAt(1) === "/") { | ||
return createTagInfo(CLOSING_TAG, offset - 2, ctx.token.string.slice(2)); | ||
} | ||
|
||
// Make sure the cursor is not after an equal sign or a quote before we report the context as a tag. | ||
if (ctx.token.string !== "=" && ctx.token.string.match(/^["']/) === null) { | ||
if (!tokenType) { | ||
|
@@ -504,14 +509,15 @@ define(function (require, exports, module) { | |
|
||
|
||
// Define public API | ||
exports.TAG_NAME = TAG_NAME; | ||
exports.ATTR_NAME = ATTR_NAME; | ||
exports.ATTR_VALUE = ATTR_VALUE; | ||
exports.TAG_NAME = TAG_NAME; | ||
exports.CLOSING_TAG = CLOSING_TAG; | ||
exports.ATTR_NAME = ATTR_NAME; | ||
exports.ATTR_VALUE = ATTR_VALUE; | ||
|
||
exports.getTagInfo = getTagInfo; | ||
exports.getTagInfo = getTagInfo; | ||
exports.getTagAttributes = getTagAttributes; | ||
//The createTagInfo is really only for the unit tests so they can make the same structure to | ||
//compare results with | ||
exports.createTagInfo = createTagInfo; | ||
exports.createTagInfo = createTagInfo; | ||
exports.findStyleBlocks = findStyleBlocks; | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,6 +186,16 @@ define(function (require, exports, module) { | |
expect(tag).toEqual(HTMLUtils.createTagInfo(HTMLUtils.TAG_NAME)); | ||
}); | ||
|
||
it("should not hint anything inside a closing tag", function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have moved this unit test to a different location in the same file. Can you restore it to the previous location so that it is next to other related unit tests? |
||
var pos = {"ch": 0, "line": 0}; | ||
setContentAndUpdatePos(pos, | ||
["<html>", "<body>", "<div id='test' class='foo'></div>"], | ||
"</body></ht", "ml>"); | ||
|
||
var tag = HTMLUtils.getTagInfo(myEditor, pos); | ||
expect(tag).toEqual(HTMLUtils.createTagInfo(HTMLUtils.CLOSING_TAG, 2, "html")); | ||
}); | ||
|
||
it("should find the tagname of the current tag if two tags are right next to each other", function () { | ||
var pos = {"ch": 0, "line": 0}; | ||
setContentAndUpdatePos(pos, | ||
|
@@ -237,16 +247,6 @@ define(function (require, exports, module) { | |
expect(tag).toEqual(HTMLUtils.createTagInfo()); | ||
}); | ||
|
||
it("should not hint anything inside a closing tag", function () { | ||
var pos = {"ch": 0, "line": 0}; | ||
setContentAndUpdatePos(pos, | ||
["<html>", "<body>", "<div id='test' class='foo'></div>"], | ||
"</body></ht", "ml>"); | ||
|
||
var tag = HTMLUtils.getTagInfo(myEditor, pos); | ||
expect(tag).toEqual(HTMLUtils.createTagInfo()); | ||
}); | ||
|
||
it("should not find attributes in an empty editor", function () { | ||
var pos = {"ch": 0, "line": 0}; | ||
var attrs = HTMLUtils.getTagAttributes(myEditor, pos); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add a new unit test for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You still need to add a unit test for Quick Edit in closing tag to test this specific change, probably in InlineEditorProviders-test.js.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems i've missed that