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

Commit

Permalink
Merge pull request #7046 from adobe/rlim/php-inside-css
Browse files Browse the repository at this point in the history
Skip all embedded php code when parsing the style blocks in php documents.
  • Loading branch information
redmunds committed Mar 24, 2014
2 parents aa994d0 + fbccf88 commit 528ef38
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/language/HTMLUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,8 @@ define(function (require, exports, module) {
currentBlock = null,
inBlock = false,
outerMode = editor._codeMirror.getMode(),
tokenModeName;
tokenModeName,
previousMode;

while (TokenUtils.moveNextToken(ctx, false)) {
tokenModeName = CodeMirror.innerMode(outerMode, ctx.token.state).mode.name;
Expand All @@ -495,7 +496,7 @@ define(function (require, exports, module) {
currentBlock.end = currentBlock.start;
}
// Check for end of this block
if (tokenModeName !== modeName) {
if (tokenModeName === previousMode) {
// currentBlock.end is already set to pos of the last token by now
currentBlock.text = editor.document.getRange(currentBlock.start, currentBlock.end);
inBlock = false;
Expand All @@ -510,6 +511,8 @@ define(function (require, exports, module) {
};
blocks.push(currentBlock);
inBlock = true;
} else {
previousMode = tokenModeName;
}
// else, random token: ignore
}
Expand Down
14 changes: 14 additions & 0 deletions test/spec/InlineEditorProviders-test-files/test1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<style type="text/css">
{{0}} body {
background: url("<?php echo $img; ?>") no-repeat;
background-size: 100% 100%;
color: white;
}
</style>
</head>

<bo{{1}}dy onclick="goHome()"></body>
</html>
15 changes: 15 additions & 0 deletions test/spec/InlineEditorProviders-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,21 @@ define(function (require, exports, module) {
});


it("should open a type selector and show correct range including the embedded php", function () {
initInlineTest("test1.php", 1);

runs(function () {
var inlineWidget = EditorManager.getCurrentFullEditor().getInlineWidgets()[0];
var inlinePos = inlineWidget.editor.getCursorPos();

// verify cursor position and displayed range in inline editor
expect(inlinePos).toEqual(infos["test1.php"].offsets[0]);
expect(inlineWidget.editor).toHaveInlineEditorRange(toRange(4, 8));

inlineWidget = null;
});
});

it("should open a type selector on opening tag", function () {
initInlineTest("test1.html", 0);

Expand Down

0 comments on commit 528ef38

Please sign in to comment.