DEV: Upgrades to Ember 3.10 (#7871)

Co-Authored-By: majakomel <maja.komel@gmail.com>
This commit is contained in:
Joffrey JAFFEUX 2019-07-16 12:45:15 +02:00 committed by GitHub
parent e2fa5704e9
commit b3eb67976d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
78 changed files with 332 additions and 263 deletions

View File

@ -51,7 +51,7 @@ gem 'onebox', '1.9.2'
gem 'http_accept_language', '~>2.0.5', require: false gem 'http_accept_language', '~>2.0.5', require: false
gem 'ember-rails', '0.18.5' gem 'ember-rails', '0.18.5'
gem 'discourse-ember-source', '~> 3.8.0' gem 'discourse-ember-source', '~> 3.10.0'
gem 'ember-handlebars-template', '0.8.0' gem 'ember-handlebars-template', '0.8.0'
gem 'barber' gem 'barber'

View File

@ -91,7 +91,7 @@ GEM
debug_inspector (0.0.3) debug_inspector (0.0.3)
diff-lcs (1.3) diff-lcs (1.3)
diffy (3.3.0) diffy (3.3.0)
discourse-ember-source (3.8.0.1) discourse-ember-source (3.10.0.1)
discourse_image_optim (0.26.2) discourse_image_optim (0.26.2)
exifr (~> 1.2, >= 1.2.2) exifr (~> 1.2, >= 1.2.2)
fspath (~> 3.0) fspath (~> 3.0)
@ -438,7 +438,7 @@ DEPENDENCIES
colored2 colored2
cppjieba_rb cppjieba_rb
diffy diffy
discourse-ember-source (~> 3.8.0) discourse-ember-source (~> 3.10.0)
discourse_image_optim discourse_image_optim
email_reply_trimmer (~> 0.1) email_reply_trimmer (~> 0.1)
ember-handlebars-template (= 0.8.0) ember-handlebars-template (= 0.8.0)

View File

@ -75,7 +75,7 @@ export default Ember.Component.extend({
if (!this.element || this.isDestroying || this.isDestroyed) { if (!this.element || this.isDestroying || this.isDestroyed) {
return; return;
} }
const editor = loadedAce.edit(this.$(".ace")[0]); const editor = loadedAce.edit(this.element.querySelector(".ace"));
editor.setTheme("ace/theme/chrome"); editor.setTheme("ace/theme/chrome");
editor.setShowPrintMargin(false); editor.setShowPrintMargin(false);
@ -89,7 +89,7 @@ export default Ember.Component.extend({
editor.$blockScrolling = Infinity; editor.$blockScrolling = Infinity;
editor.renderer.setScrollMargin(10, 10); editor.renderer.setScrollMargin(10, 10);
this.$().data("editor", editor); this.element.setAttribute("data-editor", editor);
this._editor = editor; this._editor = editor;
this.changeDisabledState(); this.changeDisabledState();

View File

@ -18,8 +18,8 @@ export default Ember.Component.extend(
}, },
_scrollDown() { _scrollDown() {
const $div = this.$()[0]; const div = this.element;
$div.scrollTop = $div.scrollHeight; div.scrollTop = div.scrollHeight;
}, },
@on("init") @on("init")

View File

@ -5,7 +5,7 @@ export default Ember.Component.extend({
type: "line", type: "line",
refreshChart() { refreshChart() {
const ctx = this.$()[0].getContext("2d"); const ctx = this.element.getContext("2d");
const model = this.model; const model = this.model;
const rawData = this.get("model.data"); const rawData = this.get("model.data");

View File

@ -35,14 +35,17 @@ export default Ember.Component.extend({
_scheduleChartRendering() { _scheduleChartRendering() {
Ember.run.schedule("afterRender", () => { Ember.run.schedule("afterRender", () => {
this._renderChart(this.model, this.$(".chart-canvas")); this._renderChart(
this.model,
this.element && this.element.querySelector(".chart-canvas")
);
}); });
}, },
_renderChart(model, $chartCanvas) { _renderChart(model, chartCanvas) {
if (!$chartCanvas || !$chartCanvas.length) return; if (!chartCanvas) return;
const context = $chartCanvas[0].getContext("2d"); const context = chartCanvas.getContext("2d");
const chartData = Ember.makeArray( const chartData = Ember.makeArray(
model.get("chartData") || model.get("data") model.get("chartData") || model.get("data")
); );

View File

@ -33,14 +33,17 @@ export default Ember.Component.extend({
_scheduleChartRendering() { _scheduleChartRendering() {
Ember.run.schedule("afterRender", () => { Ember.run.schedule("afterRender", () => {
this._renderChart(this.model, this.$(".chart-canvas")); this._renderChart(
this.model,
this.element.querySelector(".chart-canvas")
);
}); });
}, },
_renderChart(model, $chartCanvas) { _renderChart(model, chartCanvas) {
if (!$chartCanvas || !$chartCanvas.length) return; if (!chartCanvas) return;
const context = $chartCanvas[0].getContext("2d"); const context = chartCanvas.getContext("2d");
const chartData = Ember.makeArray( const chartData = Ember.makeArray(
model.get("chartData") || model.get("data") model.get("chartData") || model.get("data")

View File

@ -11,10 +11,10 @@ export default Ember.Component.extend({
classNames: ["color-picker"], classNames: ["color-picker"],
hexValueChanged: function() { hexValueChanged: function() {
var hex = this.hexValue; var hex = this.hexValue;
let $text = this.$("input.hex-input"); let text = this.element.querySelector("input.hex-input");
if (this.valid) { if (this.valid) {
$text.attr( text.setAttribute(
"style", "style",
"color: " + "color: " +
(this.brightnessValue > 125 ? "black" : "white") + (this.brightnessValue > 125 ? "black" : "white") +
@ -24,10 +24,12 @@ export default Ember.Component.extend({
); );
if (this.pickerLoaded) { if (this.pickerLoaded) {
this.$(".picker").spectrum({ color: "#" + this.hexValue }); $(this.element.querySelector(".picker")).spectrum({
color: "#" + this.hexValue
});
} }
} else { } else {
$text.attr("style", ""); text.setAttribute("style", "");
} }
}.observes("hexValue", "brightnessValue", "valid"), }.observes("hexValue", "brightnessValue", "valid"),
@ -35,7 +37,7 @@ export default Ember.Component.extend({
loadScript("/javascripts/spectrum.js").then(() => { loadScript("/javascripts/spectrum.js").then(() => {
loadCSS("/javascripts/spectrum.css").then(() => { loadCSS("/javascripts/spectrum.css").then(() => {
Ember.run.schedule("afterRender", () => { Ember.run.schedule("afterRender", () => {
this.$(".picker") $(this.element.querySelector(".picker"))
.spectrum({ color: "#" + this.hexValue }) .spectrum({ color: "#" + this.hexValue })
.on("change.spectrum", (me, color) => { .on("change.spectrum", (me, color) => {
this.set("hexValue", color.toHexString().replace("#", "")); this.set("hexValue", color.toHexString().replace("#", ""));

View File

@ -14,7 +14,7 @@ export default Ember.Component.extend(bufferedProperty("host"), {
@observes("editing") @observes("editing")
_focusOnInput() { _focusOnInput() {
Ember.run.schedule("afterRender", () => { Ember.run.schedule("afterRender", () => {
this.$(".host-name").focus(); this.element.querySelector(".host-name").focus();
}); });
}, },

View File

@ -5,6 +5,6 @@ export default Ember.Component.extend({
@on("didInsertElement") @on("didInsertElement")
@observes("code") @observes("code")
_refresh: function() { _refresh: function() {
highlightSyntax(this.$()); highlightSyntax($(this.element));
} }
}); });

View File

@ -23,10 +23,10 @@ export default Ember.Component.extend({
// If we switch to edit mode, jump to the edit textarea // If we switch to edit mode, jump to the edit textarea
if (postAction === "edit") { if (postAction === "edit") {
Ember.run.scheduleOnce("afterRender", () => { Ember.run.scheduleOnce("afterRender", () => {
let $elem = this.$(); let elem = this.element;
let body = $elem.closest(".modal-body"); let body = elem.closest(".modal-body");
body.scrollTop(body.height()); body.scrollTop(body.height());
$elem.find(".post-editor").focus(); elem.querySelector(".post-editor").focus();
}); });
} }
} }

View File

@ -19,7 +19,9 @@ export default Ember.Component.extend({
}, },
focusPermalink() { focusPermalink() {
Ember.run.schedule("afterRender", () => this.$(".permalink-url").focus()); Ember.run.schedule("afterRender", () =>
this.element.querySelector(".permalink-url").focus()
);
}, },
actions: { actions: {
@ -67,7 +69,7 @@ export default Ember.Component.extend({
this._super(...arguments); this._super(...arguments);
Ember.run.schedule("afterRender", () => { Ember.run.schedule("afterRender", () => {
this.$(".external-url").keydown(e => { $(this.element.querySelector(".external-url")).keydown(e => {
// enter key // enter key
if (e.keyCode === 13) { if (e.keyCode === 13) {
this.send("submit"); this.send("submit");

View File

@ -62,7 +62,7 @@ export default Ember.Component.extend({
this.setProperties({ ip_address: "", formSubmitted: false }); this.setProperties({ ip_address: "", formSubmitted: false });
this.action(ScreenedIpAddress.create(result.screened_ip_address)); this.action(ScreenedIpAddress.create(result.screened_ip_address));
Ember.run.schedule("afterRender", () => Ember.run.schedule("afterRender", () =>
this.$(".ip-address-input").focus() this.element.querySelector(".ip-address-input").focus()
); );
}) })
.catch(e => { .catch(e => {
@ -73,7 +73,9 @@ export default Ember.Component.extend({
error: e.jqXHR.responseJSON.errors.join(". ") error: e.jqXHR.responseJSON.errors.join(". ")
}) })
: I18n.t("generic_error"); : I18n.t("generic_error");
bootbox.alert(msg, () => this.$(".ip-address-input").focus()); bootbox.alert(msg, () =>
this.element.querySelector(".ip-address-input").focus()
);
}); });
} }
} }
@ -82,7 +84,7 @@ export default Ember.Component.extend({
@on("didInsertElement") @on("didInsertElement")
_init() { _init() {
Ember.run.schedule("afterRender", () => { Ember.run.schedule("afterRender", () => {
this.$(".ip-address-input").keydown(e => { $(this.element.querySelector(".ip-address-input")).keydown(e => {
if (e.keyCode === 13) { if (e.keyCode === 13) {
this.send("submit"); this.send("submit");
} }

View File

@ -9,11 +9,13 @@ export default Ember.Component.extend({
const term = this._searchTerm(); const term = this._searchTerm();
if (term) { if (term) {
this.$(".site-text-id, .site-text-value").highlight(term, { $(
this.element.querySelector(".site-text-id, .site-text-value")
).highlight(term, {
className: "text-highlight" className: "text-highlight"
}); });
} }
this.$(".site-text-value").ellipsis(); $(this.element.querySelector(".site-text-value")).ellipsis();
}, },
click() { click() {

View File

@ -4,19 +4,23 @@ export default Ember.Component.extend({
classNames: ["table", "staff-actions"], classNames: ["table", "staff-actions"],
willDestroyElement() { willDestroyElement() {
this.$().off("click.discourse-staff-logs"); $(this.element).off("click.discourse-staff-logs");
}, },
didInsertElement() { didInsertElement() {
this._super(...arguments); this._super(...arguments);
this.$().on("click.discourse-staff-logs", "[data-link-post-id]", e => { $(this.element).on(
let postId = $(e.target).attr("data-link-post-id"); "click.discourse-staff-logs",
"[data-link-post-id]",
e => {
let postId = $(e.target).attr("data-link-post-id");
this.store.find("post", postId).then(p => { this.store.find("post", postId).then(p => {
DiscourseURL.routeTo(p.get("url")); DiscourseURL.routeTo(p.get("url"));
}); });
return false; return false;
}); }
);
} }
}); });

View File

@ -38,8 +38,8 @@ export default Ember.Component.extend({
}, },
animate(isInitial) { animate(isInitial) {
const $container = this.$(); const $container = $(this.element);
const $list = this.$(".components-list"); const $list = $(this.element.querySelector(".components-list"));
if ($list.length === 0 || Ember.testing) { if ($list.length === 0 || Ember.testing) {
return; return;
} }

View File

@ -64,7 +64,7 @@ export default Ember.Component.extend({
}); });
this.action(WatchedWord.create(result)); this.action(WatchedWord.create(result));
Ember.run.schedule("afterRender", () => Ember.run.schedule("afterRender", () =>
this.$(".watched-word-input").focus() this.element.querySelector(".watched-word-input").focus()
); );
}) })
.catch(e => { .catch(e => {
@ -75,7 +75,9 @@ export default Ember.Component.extend({
error: e.jqXHR.responseJSON.errors.join(". ") error: e.jqXHR.responseJSON.errors.join(". ")
}) })
: I18n.t("generic_error"); : I18n.t("generic_error");
bootbox.alert(msg, () => this.$(".watched-word-input").focus()); bootbox.alert(msg, () =>
this.element.querySelector(".watched-word-input").focus()
);
}); });
} }
} }
@ -84,7 +86,7 @@ export default Ember.Component.extend({
@on("didInsertElement") @on("didInsertElement")
_init() { _init() {
Ember.run.schedule("afterRender", () => { Ember.run.schedule("afterRender", () => {
this.$(".watched-word-input").keydown(e => { $(this.element.querySelector(".watched-word-input")).keydown(e => {
if (e.keyCode === 13) { if (e.keyCode === 13) {
this.send("submit"); this.send("submit");
} }

View File

@ -90,7 +90,7 @@ export default Ember.Mixin.create({
}, },
_watchEnterKey: function() { _watchEnterKey: function() {
this.$().on("keydown.setting-enter", ".input-setting-string", e => { $(this.element).on("keydown.setting-enter", ".input-setting-string", e => {
if (e.keyCode === 13) { if (e.keyCode === 13) {
// enter key // enter key
this.send("save"); this.send("save");
@ -99,7 +99,7 @@ export default Ember.Mixin.create({
}.on("didInsertElement"), }.on("didInsertElement"),
_removeBindings: function() { _removeBindings: function() {
this.$().off("keydown.setting-enter"); $(this.element).off("keydown.setting-enter");
}.on("willDestroyElement"), }.on("willDestroyElement"),
_save() { _save() {

View File

@ -25,9 +25,9 @@ export default Ember.Component.extend({
didRender() { didRender() {
this._super(...arguments); this._super(...arguments);
const $backupCodes = this.$("#backupCodes"); const backupCodes = this.element.querySelector("#backupCodes");
if ($backupCodes.length) { if (backupCodes) {
$backupCodes.height($backupCodes[0].scrollHeight); backupCodes.style.height = backupCodes.scrollHeight;
} }
}, },
@ -49,8 +49,8 @@ export default Ember.Component.extend({
}, },
_selectAllBackupCodes() { _selectAllBackupCodes() {
const $textArea = this.$("#backupCodes"); const textArea = this.element.querySelector("#backupCodes");
$textArea[0].focus(); textArea.focus();
$textArea[0].setSelectionRange(0, this.formattedBackupCodes.length); textArea.setSelectionRange(0, this.formattedBackupCodes.length);
} }
}); });

View File

@ -35,7 +35,7 @@ export default Ember.Component.extend(UploadMixin, {
}, },
_init: function() { _init: function() {
const $upload = this.$(); const $upload = $(this.element);
$upload.on("fileuploadadd", (e, data) => { $upload.on("fileuploadadd", (e, data) => {
ajax("/admin/backups/upload_url", { ajax("/admin/backups/upload_url", {

View File

@ -93,9 +93,9 @@ export default Ember.Component.extend(KeyEnterEscape, {
}, },
setupComposerResizeEvents() { setupComposerResizeEvents() {
const $composer = this.$(); const $composer = $(this.element);
const $grippie = this.$(".grippie"); const $grippie = $(this.element.querySelector(".grippie"));
const $document = Ember.$(document); const $document = $(document);
let origComposerSize = 0; let origComposerSize = 0;
let lastMousePos = 0; let lastMousePos = 0;
@ -105,7 +105,7 @@ export default Ember.Component.extend(KeyEnterEscape, {
const currentMousePos = mouseYPos(event); const currentMousePos = mouseYPos(event);
let size = origComposerSize + (lastMousePos - currentMousePos); let size = origComposerSize + (lastMousePos - currentMousePos);
const winHeight = Ember.$(window).height(); const winHeight = $(window).height();
size = Math.min(size, winHeight - headerHeight()); size = Math.min(size, winHeight - headerHeight());
size = Math.max(size, MIN_COMPOSER_SIZE); size = Math.max(size, MIN_COMPOSER_SIZE);
this.movePanels(size); this.movePanels(size);
@ -145,11 +145,11 @@ export default Ember.Component.extend(KeyEnterEscape, {
}; };
triggerOpen(); triggerOpen();
afterTransition(this.$(), () => { afterTransition($(this.element), () => {
resize(); resize();
triggerOpen(); triggerOpen();
}); });
positioningWorkaround(this.$()); positioningWorkaround($(this.element));
}, },
willDestroyElement() { willDestroyElement() {

View File

@ -112,7 +112,7 @@ export default Ember.Component.extend({
@observes("focusTarget") @observes("focusTarget")
setFocus() { setFocus() {
if (this.focusTarget === "editor") { if (this.focusTarget === "editor") {
this.$("textarea").putCursorAtEnd(); $(this.element.querySelector("textarea")).putCursorAtEnd();
} }
}, },
@ -158,8 +158,8 @@ export default Ember.Component.extend({
@on("didInsertElement") @on("didInsertElement")
_composerEditorInit() { _composerEditorInit() {
const topicId = this.get("topic.id"); const topicId = this.get("topic.id");
const $input = this.$(".d-editor-input"); const $input = $(this.element.querySelector(".d-editor-input"));
const $preview = this.$(".d-editor-preview-wrapper"); const $preview = $(this.element.querySelector(".d-editor-preview-wrapper"));
if (this.siteSettings.enable_mentions) { if (this.siteSettings.enable_mentions) {
$input.autocomplete({ $input.autocomplete({
@ -206,7 +206,7 @@ export default Ember.Component.extend({
!this.get("composer.canEditTitle") && !this.get("composer.canEditTitle") &&
(!this.capabilities.isIOS || safariHacksDisabled()) (!this.capabilities.isIOS || safariHacksDisabled())
) { ) {
this.$(".d-editor-input").putCursorAtEnd(); $(this.element.querySelector(".d-editor-input")).putCursorAtEnd();
} }
this._bindUploadTarget(); this._bindUploadTarget();
@ -345,12 +345,13 @@ export default Ember.Component.extend({
}, },
_teardownInputPreviewSync() { _teardownInputPreviewSync() {
[this.$(".d-editor-input"), this.$(".d-editor-preview-wrapper")].forEach( [
$element => { $(this.element.querySelector(".d-editor-input")),
$element.off("mouseenter touchstart"); $(this.element.querySelector(".d-editor-preview-wrapper"))
$element.off("scroll"); ].forEach($element => {
} $element.off("mouseenter touchstart");
); $element.off("scroll");
});
REBUILD_SCROLL_MAP_EVENTS.forEach(event => { REBUILD_SCROLL_MAP_EVENTS.forEach(event => {
this.appEvents.off(event, this, this._resetShouldBuildScrollMap); this.appEvents.off(event, this, this._resetShouldBuildScrollMap);
@ -647,7 +648,7 @@ export default Ember.Component.extend({
this._unbindUploadTarget(); // in case it's still bound, let's clean it up first this._unbindUploadTarget(); // in case it's still bound, let's clean it up first
this._pasted = false; this._pasted = false;
const $element = this.$(); const $element = $(this.element);
const csrf = this.session.get("csrfToken"); const csrf = this.session.get("csrfToken");
$element.fileupload({ $element.fileupload({
@ -890,7 +891,7 @@ export default Ember.Component.extend({
this._validUploads = 0; this._validUploads = 0;
$("#reply-control .mobile-file-upload").off("click.uploader"); $("#reply-control .mobile-file-upload").off("click.uploader");
this.messageBus.unsubscribe("/uploads/composer"); this.messageBus.unsubscribe("/uploads/composer");
const $uploadTarget = this.$(); const $uploadTarget = $(this.element);
try { try {
$uploadTarget.fileupload("destroy"); $uploadTarget.fileupload("destroy");
} catch (e) { } catch (e) {
@ -925,7 +926,7 @@ export default Ember.Component.extend({
}, },
showPreview() { showPreview() {
const $preview = this.$(".d-editor-preview-wrapper"); const $preview = $(this.element.querySelector(".d-editor-preview-wrapper"));
this._placeImageScaleButtons($preview); this._placeImageScaleButtons($preview);
this.send("togglePreview"); this.send("togglePreview");
}, },
@ -1071,7 +1072,7 @@ export default Ember.Component.extend({
if (this._enableAdvancedEditorPreviewSync()) { if (this._enableAdvancedEditorPreviewSync()) {
this._syncScroll( this._syncScroll(
this._syncEditorAndPreviewScroll, this._syncEditorAndPreviewScroll,
this.$(".d-editor-input"), $(this.element.querySelector(".d-editor-input")),
$preview $preview
); );
} }

View File

@ -11,7 +11,7 @@ export default Ember.Component.extend({
didInsertElement() { didInsertElement() {
this._super(...arguments); this._super(...arguments);
this.$().show(); this.element.style.display = "block";
}, },
actions: { actions: {

View File

@ -14,9 +14,9 @@ export default Ember.Component.extend({
didInsertElement() { didInsertElement() {
this._super(...arguments); this._super(...arguments);
if (this.focusTarget === "title") { if (this.focusTarget === "title") {
const $input = this.$("input"); const $input = $(this.element.querySelector("input"));
afterTransition(this.$().closest("#reply-control"), () => { afterTransition($(this.element).closest("#reply-control"), () => {
$input.putCursorAtEnd(); $input.putCursorAtEnd();
}); });
} }
@ -133,14 +133,14 @@ export default Ember.Component.extend({
.finally(() => { .finally(() => {
this.set("composer.loading", false); this.set("composer.loading", false);
Ember.run.schedule("afterRender", () => { Ember.run.schedule("afterRender", () => {
this.$("input").putCursorAtEnd(); $(this.element.querySelector("input")).putCursorAtEnd();
}); });
}); });
} else { } else {
this._updatePost(loadOnebox); this._updatePost(loadOnebox);
this.set("composer.loading", false); this.set("composer.loading", false);
Ember.run.schedule("afterRender", () => { Ember.run.schedule("afterRender", () => {
this.$("input").putCursorAtEnd(); $(this.element.querySelector("input")).putCursorAtEnd();
}); });
} }
} }

View File

@ -12,14 +12,14 @@ export default Ember.Component.extend({
this._super(...arguments); this._super(...arguments);
if (this.focusTarget === "usernames") { if (this.focusTarget === "usernames") {
this.$("input").putCursorAtEnd(); $(this.element.querySelector("input")).putCursorAtEnd();
} }
}, },
@observes("usernames") @observes("usernames")
_checkWidth() { _checkWidth() {
let width = 0; let width = 0;
const $acWrap = this.$().find(".ac-wrap"); const $acWrap = $(this.element).find(".ac-wrap");
const limit = $acWrap.width(); const limit = $acWrap.width();
this.set("defaultUsernameCount", 0); this.set("defaultUsernameCount", 0);
@ -76,7 +76,7 @@ export default Ember.Component.extend({
this.set("showSelector", true); this.set("showSelector", true);
Ember.run.schedule("afterRender", () => { Ember.run.schedule("afterRender", () => {
this.$() $(this.element)
.find("input") .find("input")
.focus(); .focus();
}); });
@ -84,7 +84,7 @@ export default Ember.Component.extend({
triggerResize() { triggerResize() {
this.appEvents.trigger("composer:resize"); this.appEvents.trigger("composer:resize");
const $this = this.$().find(".ac-wrap"); const $this = $(this.element).find(".ac-wrap");
if ($this.height() >= 150) $this.scrollTop($this.height()); if ($this.height() >= 150) $this.scrollTop($this.height());
} }
} }

View File

@ -8,7 +8,7 @@ export default Ember.Component.extend({
this.set("email", $.cookie("email")); this.set("email", $.cookie("email"));
} }
this.$().on("keydown.discourse-create-account", e => { $(this.element).on("keydown.discourse-create-account", e => {
if (!this.disabled && e.keyCode === 13) { if (!this.disabled && e.keyCode === 13) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@ -17,7 +17,7 @@ export default Ember.Component.extend({
} }
}); });
this.$().on("click.dropdown-user-field-label", "[for]", event => { $(this.element).on("click.dropdown-user-field-label", "[for]", event => {
const $element = $(event.target); const $element = $(event.target);
const $target = $(`#${$element.attr("for")}`); const $target = $(`#${$element.attr("for")}`);
@ -31,7 +31,7 @@ export default Ember.Component.extend({
willDestroyElement() { willDestroyElement() {
this._super(...arguments); this._super(...arguments);
this.$().off("keydown.discourse-create-account"); $(this.element).off("keydown.discourse-create-account");
this.$().off("click.dropdown-user-field-label"); $(this.element).off("click.dropdown-user-field-label");
} }
}); });

View File

@ -32,7 +32,7 @@ export default Ember.Component.extend(UploadMixin, {
}, },
_init: function() { _init: function() {
const $upload = this.$(); const $upload = $(this.element);
$upload.on("fileuploadadd", (e, data) => { $upload.on("fileuploadadd", (e, data) => {
bootbox.confirm( bootbox.confirm(

View File

@ -7,8 +7,8 @@ export default Ember.Component.extend({
_hiddenChanged() { _hiddenChanged() {
if (!this.hidden) { if (!this.hidden) {
Ember.run.scheduleOnce("afterRender", () => { Ember.run.scheduleOnce("afterRender", () => {
const $modal = this.$(); const $modal = $(this.element);
const $parent = this.$().closest(".d-editor"); const $parent = $(this.element).closest(".d-editor");
const w = $parent.width(); const w = $parent.width();
const h = $parent.height(); const h = $parent.height();
const dir = $("html").css("direction") === "rtl" ? "right" : "left"; const dir = $("html").css("direction") === "rtl" ? "right" : "left";
@ -27,7 +27,7 @@ export default Ember.Component.extend({
@on("didInsertElement") @on("didInsertElement")
_listenKeys() { _listenKeys() {
this.$().on("keydown.d-modal", key => { $(this.element).on("keydown.d-modal", key => {
if (this.hidden) { if (this.hidden) {
return; return;
} }
@ -45,7 +45,7 @@ export default Ember.Component.extend({
@on("willDestroyElement") @on("willDestroyElement")
_stopListening() { _stopListening() {
this.$().off("keydown.d-modal"); $(this.element).off("keydown.d-modal");
}, },
actions: { actions: {

View File

@ -231,7 +231,7 @@ export default Ember.Component.extend({
this.set("ready", true); this.set("ready", true);
if (this.autofocus) { if (this.autofocus) {
this.$("textarea").focus(); this.element.querySelector("textarea").focus();
} }
}, },
@ -244,13 +244,13 @@ export default Ember.Component.extend({
didInsertElement() { didInsertElement() {
this._super(...arguments); this._super(...arguments);
const $editorInput = this.$(".d-editor-input"); const $editorInput = $(this.element.querySelector(".d-editor-input"));
this._applyEmojiAutocomplete($editorInput); this._applyEmojiAutocomplete($editorInput);
this._applyCategoryHashtagAutocomplete($editorInput); this._applyCategoryHashtagAutocomplete($editorInput);
Ember.run.scheduleOnce("afterRender", this, this._readyNow); Ember.run.scheduleOnce("afterRender", this, this._readyNow);
const mouseTrap = Mousetrap(this.$(".d-editor-input")[0]); const mouseTrap = Mousetrap(this.element.querySelector(".d-editor-input"));
const shortcuts = this.get("toolbar.shortcuts"); const shortcuts = this.get("toolbar.shortcuts");
Object.keys(shortcuts).forEach(sc => { Object.keys(shortcuts).forEach(sc => {
@ -262,28 +262,31 @@ export default Ember.Component.extend({
}); });
// disable clicking on links in the preview // disable clicking on links in the preview
this.$(".d-editor-preview").on("click.preview", e => { $(this.element.querySelector(".d-editor-preview")).on(
if (wantsNewWindow(e)) { "click.preview",
return; e => {
if (wantsNewWindow(e)) {
return;
}
const $target = $(e.target);
if ($target.is("a.mention")) {
this.appEvents.trigger(
"click.discourse-preview-user-card-mention",
$target
);
}
if ($target.is("a.mention-group")) {
this.appEvents.trigger(
"click.discourse-preview-group-card-mention-group",
$target
);
}
if ($target.is("a")) {
e.preventDefault();
return false;
}
} }
const $target = $(e.target); );
if ($target.is("a.mention")) {
this.appEvents.trigger(
"click.discourse-preview-user-card-mention",
$target
);
}
if ($target.is("a.mention-group")) {
this.appEvents.trigger(
"click.discourse-preview-group-card-mention-group",
$target
);
}
if ($target.is("a")) {
e.preventDefault();
return false;
}
});
if (this.composerEvents) { if (this.composerEvents) {
this.appEvents.on("composer:insert-block", this, "_insertBlock"); this.appEvents.on("composer:insert-block", this, "_insertBlock");
@ -313,7 +316,7 @@ export default Ember.Component.extend({
Object.keys(this.get("toolbar.shortcuts")).forEach(sc => Object.keys(this.get("toolbar.shortcuts")).forEach(sc =>
mouseTrap.unbind(sc) mouseTrap.unbind(sc)
); );
this.$(".d-editor-preview").off("click.preview"); $(this.element.querySelector(".d-editor-preview")).off("click.preview");
}, },
@computed @computed
@ -348,7 +351,7 @@ export default Ember.Component.extend({
if (this._state !== "inDOM") { if (this._state !== "inDOM") {
return; return;
} }
const $preview = this.$(".d-editor-preview"); const $preview = $(this.element.querySelector(".d-editor-preview"));
if ($preview.length === 0) return; if ($preview.length === 0) return;
if (this.previewUpdated) { if (this.previewUpdated) {
@ -375,7 +378,7 @@ export default Ember.Component.extend({
_applyCategoryHashtagAutocomplete() { _applyCategoryHashtagAutocomplete() {
const siteSettings = this.siteSettings; const siteSettings = this.siteSettings;
this.$(".d-editor-input").autocomplete({ $(this.element.querySelector(".d-editor-input")).autocomplete({
template: findRawTemplate("category-tag-autocomplete"), template: findRawTemplate("category-tag-autocomplete"),
key: "#", key: "#",
afterComplete: () => this._focusTextArea(), afterComplete: () => this._focusTextArea(),
@ -500,7 +503,7 @@ export default Ember.Component.extend({
return; return;
} }
const textarea = this.$("textarea.d-editor-input")[0]; const textarea = this.element.querySelector("textarea.d-editor-input");
const value = textarea.value; const value = textarea.value;
let start = textarea.selectionStart; let start = textarea.selectionStart;
let end = textarea.selectionEnd; let end = textarea.selectionEnd;
@ -533,8 +536,8 @@ export default Ember.Component.extend({
_selectText(from, length) { _selectText(from, length) {
Ember.run.scheduleOnce("afterRender", () => { Ember.run.scheduleOnce("afterRender", () => {
const $textarea = this.$("textarea.d-editor-input"); const textarea = this.element.querySelector("textarea.d-editor-input");
const textarea = $textarea[0]; const $textarea = $(textarea);
const oldScrollPos = $textarea.scrollTop(); const oldScrollPos = $textarea.scrollTop();
if (!this.capabilities.isIOS || safariHacksDisabled()) { if (!this.capabilities.isIOS || safariHacksDisabled()) {
$textarea.focus(); $textarea.focus();
@ -687,7 +690,7 @@ export default Ember.Component.extend({
return; return;
} }
const textarea = this.$("textarea.d-editor-input")[0]; const textarea = this.element.querySelector("textarea.d-editor-input");
// Determine post-replace selection. // Determine post-replace selection.
const newSelection = determinePostReplaceSelection({ const newSelection = determinePostReplaceSelection({
@ -737,7 +740,7 @@ export default Ember.Component.extend({
} }
const value = pre + text + post; const value = pre + text + post;
const $textarea = this.$("textarea.d-editor-input"); const $textarea = $(this.element.querySelector("textarea.d-editor-input"));
this.set("value", value); this.set("value", value);
@ -749,7 +752,7 @@ export default Ember.Component.extend({
}, },
_addText(sel, text, options) { _addText(sel, text, options) {
const $textarea = this.$("textarea.d-editor-input"); const $textarea = $(this.element.querySelector("textarea.d-editor-input"));
if (options && options.ensureSpace) { if (options && options.ensureSpace) {
if ((sel.pre + "").length > 0) { if ((sel.pre + "").length > 0) {
@ -870,8 +873,11 @@ export default Ember.Component.extend({
// ensures textarea scroll position is correct // ensures textarea scroll position is correct
_focusTextArea() { _focusTextArea() {
const $textarea = this.$("textarea.d-editor-input"); const textarea = this.element.querySelector("textarea.d-editor-input");
Ember.run.scheduleOnce("afterRender", () => $textarea.blur().focus()); Ember.run.scheduleOnce("afterRender", () => {
textarea.blur();
textarea.focus();
});
}, },
actions: { actions: {

View File

@ -7,7 +7,7 @@ export default Ember.Component.extend({
this._super(...arguments); this._super(...arguments);
$("#modal-alert").hide(); $("#modal-alert").hide();
let fixedParent = this.$().closest(".d-modal.fixed-modal"); let fixedParent = $(this.element).closest(".d-modal.fixed-modal");
if (fixedParent.length) { if (fixedParent.length) {
this.set("fixed", true); this.set("fixed", true);
fixedParent.modal("show"); fixedParent.modal("show");
@ -26,8 +26,12 @@ export default Ember.Component.extend({
}, },
_afterFirstRender() { _afterFirstRender() {
if (!this.site.mobileView && this.autoFocus !== "false") { if (
this.$("input:first").focus(); !this.site.mobileView &&
this.autoFocus !== "false" &&
this.element.querySelector("input")
) {
this.element.querySelector("input").focus();
} }
const maxHeight = this.maxHeight; const maxHeight = this.maxHeight;
@ -35,7 +39,7 @@ export default Ember.Component.extend({
const maxHeightFloat = parseFloat(maxHeight) / 100.0; const maxHeightFloat = parseFloat(maxHeight) / 100.0;
if (maxHeightFloat > 0) { if (maxHeightFloat > 0) {
const viewPortHeight = $(window).height(); const viewPortHeight = $(window).height();
this.$().css( $(this.element).css(
"max-height", "max-height",
Math.floor(maxHeightFloat * viewPortHeight) + "px" Math.floor(maxHeightFloat * viewPortHeight) + "px"
); );

View File

@ -66,7 +66,7 @@ export default Ember.Component.extend({
} }
if (data.fixed) { if (data.fixed) {
this.$().removeClass("hidden"); this.element.classList.remove("hidden");
} }
if (data.title) { if (data.title) {

View File

@ -102,7 +102,7 @@ export default Ember.Component.extend(
$(window).on("resize.discourse-on-scroll", () => this.scrolled()); $(window).on("resize.discourse-on-scroll", () => this.scrolled());
this.$().on( $(this.element).on(
"click.discourse-redirect", "click.discourse-redirect",
".cooked a, a.track-link", ".cooked a, a.track-link",
function(e) { function(e) {
@ -120,7 +120,10 @@ export default Ember.Component.extend(
$(window).unbind("resize.discourse-on-scroll"); $(window).unbind("resize.discourse-on-scroll");
// Unbind link tracking // Unbind link tracking
this.$().off("click.discourse-redirect", ".cooked a, a.track-link"); $(this.element).off(
"click.discourse-redirect",
".cooked a, a.track-link"
);
this.resetExamineDockCache(); this.resetExamineDockCache();

View File

@ -27,7 +27,7 @@ export default Ember.Component.extend({
}, },
_resetModalScrollState() { _resetModalScrollState() {
const $modalBody = this.$() const $modalBody = $(this.element)
.parents("#discourse-modal") .parents("#discourse-modal")
.find(".modal-body"); .find(".modal-body");
if ($modalBody.length === 1) { if ($modalBody.length === 1) {

View File

@ -4,7 +4,7 @@ export default buildCategoryPanel("topic-template", {
_activeTabChanged: function() { _activeTabChanged: function() {
if (this.activeTab) { if (this.activeTab) {
Ember.run.scheduleOnce("afterRender", () => Ember.run.scheduleOnce("afterRender", () =>
this.$(".d-editor-input").focus() this.element.querySelector(".d-editor-input").focus()
); );
} }
}.observes("activeTab") }.observes("activeTab")

View File

@ -86,8 +86,8 @@ export default Ember.Component.extend({
@on("didInsertElement") @on("didInsertElement")
_setup() { _setup() {
this.$picker = this.$(".emoji-picker"); this.$picker = $(this.element.querySelector(".emoji-picker"));
this.$modal = this.$(".emoji-picker-modal"); this.$modal = $(this.element.querySelector(".emoji-picker-modal"));
this.appEvents.on("emoji-picker:close", this, "_closeEmojiPicker"); this.appEvents.on("emoji-picker:close", this, "_closeEmojiPicker");
@ -228,8 +228,8 @@ export default Ember.Component.extend({
@on("willDestroyElement") @on("willDestroyElement")
_unbindEvents() { _unbindEvents() {
this.$().off(); $(this.element).off();
this.$(window).off("resize"); $(window).off("resize");
clearInterval(this._refreshInterval); clearInterval(this._refreshInterval);
$("#reply-control").off("div-resizing"); $("#reply-control").off("div-resizing");
$("html").off("mouseup.emoji-picker"); $("html").off("mouseup.emoji-picker");
@ -312,7 +312,7 @@ export default Ember.Component.extend({
}, },
_bindResizing() { _bindResizing() {
this.$(window).on("resize", () => { $(window).on("resize", () => {
run.throttle(this, this._positionPicker, 16); run.throttle(this, this._positionPicker, 16);
}); });
@ -468,7 +468,7 @@ export default Ember.Component.extend({
_isReplyControlExpanded() { _isReplyControlExpanded() {
const verticalSpace = const verticalSpace =
this.$(window).height() - $(window).height() -
$(".d-header").height() - $(".d-header").height() -
$("#reply-control").height(); $("#reply-control").height();
@ -480,7 +480,7 @@ export default Ember.Component.extend({
return; return;
} }
let windowWidth = this.$(window).width(); let windowWidth = $(window).width();
const desktopModalePositioning = options => { const desktopModalePositioning = options => {
let attributes = { let attributes = {

View File

@ -5,7 +5,7 @@ export default Ember.TextArea.extend({
@on("didInsertElement") @on("didInsertElement")
_startWatching() { _startWatching() {
Ember.run.scheduleOnce("afterRender", () => { Ember.run.scheduleOnce("afterRender", () => {
this.$().focus(); $(this.element).focus();
autosize(this.element); autosize(this.element);
}); });
}, },
@ -19,6 +19,6 @@ export default Ember.TextArea.extend({
@on("willDestroyElement") @on("willDestroyElement")
_disableAutosize() { _disableAutosize() {
autosize.destroy(this.$()); autosize.destroy($(this.element));
} }
}); });

View File

@ -3,14 +3,14 @@ import { observes } from "ember-addons/ember-computed-decorators";
// Mostly hacks because `flag.hbs` didn't use `radio-button` // Mostly hacks because `flag.hbs` didn't use `radio-button`
export default Ember.Component.extend({ export default Ember.Component.extend({
_selectRadio() { _selectRadio() {
this.$("input[type='radio']").prop("checked", false); this.element.querySelector("input[type='radio']").checked = false;
const nameKey = this.nameKey; const nameKey = this.nameKey;
if (!nameKey) { if (!nameKey) {
return; return;
} }
this.$("#radio_" + nameKey).prop("checked", "true"); this.element.querySelector("#radio_" + nameKey).checked = "true";
}, },
@observes("nameKey") @observes("nameKey")

View File

@ -91,7 +91,7 @@ const FooterNavComponent = MountWidget.extend(
// in the header, otherwise, we hide it. // in the header, otherwise, we hide it.
@observes("mobileScrollDirection") @observes("mobileScrollDirection")
toggleMobileFooter() { toggleMobileFooter() {
this.$().toggleClass( $(this.element).toggleClass(
"visible", "visible",
this.mobileScrollDirection === null ? true : false this.mobileScrollDirection === null ? true : false
); );

View File

@ -1,7 +1,7 @@
export default Ember.Component.extend({ export default Ember.Component.extend({
didInsertElement() { didInsertElement() {
this._super(...arguments); this._super(...arguments);
this.$("input") $(this.element.querySelector("input"))
.select() .select()
.focus(); .focus();
} }

View File

@ -22,7 +22,7 @@ export default Ember.Component.extend({
let selectedGroups; let selectedGroups;
let groupNames = this.groupNames; let groupNames = this.groupNames;
this.$("input").autocomplete({ $(this.element.querySelector("input")).autocomplete({
allowAny: false, allowAny: false,
items: _.isArray(groupNames) items: _.isArray(groupNames)
? groupNames ? groupNames

View File

@ -5,7 +5,7 @@ export default Ember.Component.extend({
_highlightOnInsert: function() { _highlightOnInsert: function() {
const term = this.highlight; const term = this.highlight;
highlightText(this.$(), term); highlightText($(this.element), term);
} }
.observes("highlight") .observes("highlight")
.on("didInsertElement") .on("didInsertElement")

View File

@ -76,11 +76,13 @@ export default Ember.Component.extend(UploadMixin, {
}, },
_openLightbox() { _openLightbox() {
Ember.run.next(() => this.$("a.lightbox").magnificPopup("open")); Ember.run.next(() =>
$(this.element.querySelector("a.lightbox")).magnificPopup("open")
);
}, },
_applyLightbox() { _applyLightbox() {
if (this.imageUrl) Ember.run.next(() => lightbox(this.$())); if (this.imageUrl) Ember.run.next(() => lightbox($(this.element)));
}, },
actions: { actions: {

View File

@ -5,7 +5,7 @@ export default Ember.Component.extend({
this.onClick(); this.onClick();
Ember.run.schedule("afterRender", () => { Ember.run.schedule("afterRender", () => {
this.$() $(this.element)
.find("input") .find("input")
.focus(); .focus();
}); });

View File

@ -24,9 +24,9 @@ export default Ember.Component.extend({
}, },
_updateSelectedHtml() { _updateSelectedHtml() {
const active = this.$(".active"); const active = this.element.querySelector(".active");
if (active && active.html) { if (active && active.innerHTML) {
this.set("selectedHtml", active.html()); this.set("selectedHtml", active.innerHTML);
} }
}, },
@ -43,7 +43,7 @@ export default Ember.Component.extend({
$(window) $(window)
.off("click.mobile-nav") .off("click.mobile-nav")
.on("click.mobile-nav", e => { .on("click.mobile-nav", e => {
let expander = this.$(".expander"); let expander = $(this.element.querySelector(".expander"));
expander = expander && expander[0]; expander = expander && expander[0];
if ($(e.target)[0] !== expander) { if ($(e.target)[0] !== expander) {
this.set("expanded", false); this.set("expanded", false);

View File

@ -73,8 +73,8 @@ export default Ember.Component.extend({
return; return;
} }
this.$(".drop a").on("click", () => { $(this.element.querySelector(".drop a")).on("click", () => {
this.$(".drop").hide(); this.element.querySelector(".drop").style.display = "none";
Ember.run.next(() => { Ember.run.next(() => {
if (!this.element || this.isDestroying || this.isDestroyed) { if (!this.element || this.isDestroying || this.isDestroyed) {

View File

@ -29,7 +29,7 @@ export default Ember.Component.extend(
@observes("lastShownAt") @observes("lastShownAt")
bounce() { bounce() {
if (this.lastShownAt) { if (this.lastShownAt) {
var $elem = this.$(); var $elem = $(this.element);
if (!this.animateAttribute) { if (!this.animateAttribute) {
this.animateAttribute = this.animateAttribute =
$elem.css("left") === "auto" ? "right" : "left"; $elem.css("left") === "auto" ? "right" : "left";

View File

@ -83,7 +83,7 @@ export default Ember.Component.extend({
const $markerElement = $(markerElement); const $markerElement = $(markerElement);
const markerOffset = $markerElement.offset(); const markerOffset = $markerElement.offset();
const parentScrollLeft = $markerElement.parent().scrollLeft(); const parentScrollLeft = $markerElement.parent().scrollLeft();
const $quoteButton = this.$(); const $quoteButton = $(this.element);
// remove the marker // remove the marker
const parent = markerElement.parentNode; const parent = markerElement.parentNode;

View File

@ -12,7 +12,7 @@ export default Ember.Component.extend({
], ],
click() { click() {
const value = this.$().val(); const value = $(this.element).val();
if (this.selection === value) { if (this.selection === value) {
this.set("selection", undefined); this.set("selection", undefined);
} }

View File

@ -89,7 +89,9 @@ export default MountWidget.extend({
const windowTop = $w.scrollTop(); const windowTop = $w.scrollTop();
const postsWrapperTop = $(".posts-wrapper").offset().top; const postsWrapperTop = $(".posts-wrapper").offset().top;
const $posts = this.$(".onscreen-post, .cloaked-post"); const $posts = $(
this.element.querySelectorAll(".onscreen-post, .cloaked-post")
);
const viewportTop = windowTop - slack; const viewportTop = windowTop - slack;
const topView = findTopView( const topView = findTopView(
$posts, $posts,
@ -314,12 +316,12 @@ export default MountWidget.extend({
this.appEvents.on("post-stream:posted", this, "_posted"); this.appEvents.on("post-stream:posted", this, "_posted");
this.$().on("mouseenter.post-stream", "button.widget-button", e => { $(this.element).on("mouseenter.post-stream", "button.widget-button", e => {
$("button.widget-button").removeClass("d-hover"); $("button.widget-button").removeClass("d-hover");
$(e.target).addClass("d-hover"); $(e.target).addClass("d-hover");
}); });
this.$().on("mouseleave.post-stream", "button.widget-button", () => { $(this.element).on("mouseleave.post-stream", "button.widget-button", () => {
$("button.widget-button").removeClass("d-hover"); $("button.widget-button").removeClass("d-hover");
}); });
@ -331,8 +333,8 @@ export default MountWidget.extend({
$(document).unbind("touchmove.post-stream"); $(document).unbind("touchmove.post-stream");
$(window).unbind("scroll.post-stream"); $(window).unbind("scroll.post-stream");
this.appEvents.off("post-stream:refresh", this, "_debouncedScroll"); this.appEvents.off("post-stream:refresh", this, "_debouncedScroll");
this.$().off("mouseenter.post-stream"); $(this.element).off("mouseenter.post-stream");
this.$().off("mouseleave.post-stream"); $(this.element).off("mouseleave.post-stream");
this.appEvents.off("post-stream:refresh", this, "_refresh"); this.appEvents.off("post-stream:refresh", this, "_refresh");
this.appEvents.off("post-stream:posted", this, "_posted"); this.appEvents.off("post-stream:posted", this, "_posted");
} }

View File

@ -13,7 +13,7 @@ export default TextField.extend({
@on("didInsertElement") @on("didInsertElement")
becomeFocused() { becomeFocused() {
const $searchInput = this.$(); const $searchInput = $(this.element);
applySearchAutocomplete($searchInput, this.siteSettings); applySearchAutocomplete($searchInput, this.siteSettings);
if (!this.hasAutofocus) { if (!this.hasAutofocus) {

View File

@ -41,8 +41,10 @@ export default Ember.Component.extend({
this._super(...arguments); this._super(...arguments);
const shareUrl = this.shareUrl; const shareUrl = this.shareUrl;
const $linkInput = this.$(".topic-share-url"); const $linkInput = $(this.element.querySelector(".topic-share-url"));
const $linkForTouch = this.$(".topic-share-url-for-touch a"); const $linkForTouch = $(
this.element.querySelector(".topic-share-url-for-touch a")
);
Ember.run.schedule("afterRender", () => { Ember.run.schedule("afterRender", () => {
if (!this.capabilities.touch) { if (!this.capabilities.touch) {

View File

@ -54,7 +54,7 @@ export default Ember.Component.extend({
_showUrl($target, url) { _showUrl($target, url) {
const $currentTargetOffset = $target.offset(); const $currentTargetOffset = $target.offset();
const $this = this.$(); const $this = $(this.element);
if (Ember.isEmpty(url)) { if (Ember.isEmpty(url)) {
return; return;

View File

@ -124,7 +124,7 @@ const SiteHeaderComponent = MountWidget.extend(Docking, PanEvents, {
this._isPanning = true; this._isPanning = true;
} else if ( } else if (
center.x < SCREEN_EDGE_MARGIN && center.x < SCREEN_EDGE_MARGIN &&
!this.$(".menu-panel").length && !this.element.querySelector(".menu-panel") &&
e.direction === "right" e.direction === "right"
) { ) {
this._animate = false; this._animate = false;
@ -136,7 +136,7 @@ const SiteHeaderComponent = MountWidget.extend(Docking, PanEvents, {
window.requestAnimationFrame(() => this.panMove(e)); window.requestAnimationFrame(() => this.panMove(e));
} else if ( } else if (
windowWidth - center.x < SCREEN_EDGE_MARGIN && windowWidth - center.x < SCREEN_EDGE_MARGIN &&
!this.$(".menu-panel").length && !this.element.querySelector(".menu-panel") &&
e.direction === "left" e.direction === "left"
) { ) {
this._animate = false; this._animate = false;
@ -245,7 +245,7 @@ const SiteHeaderComponent = MountWidget.extend(Docking, PanEvents, {
_cleanDom() { _cleanDom() {
// For performance, only trigger a re-render if any menu panels are visible // For performance, only trigger a re-render if any menu panels are visible
if (this.$(".menu-panel").length) { if (this.element.querySelector(".menu-panel")) {
this.eventDispatched("dom:clean", "header"); this.eventDispatched("dom:clean", "header");
} }
}, },

View File

@ -2,7 +2,7 @@ export default Ember.Component.extend({
didInsertElement() { didInsertElement() {
this._super(...arguments); this._super(...arguments);
Ember.run.next(null, () => { Ember.run.next(null, () => {
const $this = this.$(); const $this = $(this.element);
if ($this) { if ($this) {
$this.find("hr").remove(); $this.find("hr").remove();

View File

@ -153,7 +153,7 @@ export const ListItemDefaults = {
navigateToTopic, navigateToTopic,
highlight(opts = { isLastViewedTopic: false }) { highlight(opts = { isLastViewedTopic: false }) {
const $topic = this.$(); const $topic = $(this.element);
$topic $topic
.addClass("highlighted") .addClass("highlighted")
.attr("data-islastviewedtopic", opts.isLastViewedTopic); .attr("data-islastviewedtopic", opts.isLastViewedTopic);

View File

@ -126,7 +126,7 @@ export default Ember.Component.extend({
return; return;
} }
const $topicProgress = this.$("#topic-progress"); const $topicProgress = $(this.element.querySelector("#topic-progress"));
// speeds up stuff, bypass jquery slowness and extra checks // speeds up stuff, bypass jquery slowness and extra checks
if (!this._totalWidth) { if (!this._totalWidth) {
this._totalWidth = $topicProgress[0].offsetWidth; this._totalWidth = $topicProgress[0].offsetWidth;
@ -151,7 +151,7 @@ export default Ember.Component.extend({
}, },
_dock() { _dock() {
const $wrapper = this.$(); const $wrapper = $(this.element);
if (!$wrapper || $wrapper.length === 0) return; if (!$wrapper || $wrapper.length === 0) return;
const $html = $("html"); const $html = $("html");

View File

@ -52,8 +52,8 @@ export default MountWidget.extend(Docking, {
const offsetTop = mainOffset ? mainOffset.top : 0; const offsetTop = mainOffset ? mainOffset.top : 0;
const topicTop = $(".container.posts").offset().top - offsetTop; const topicTop = $(".container.posts").offset().top - offsetTop;
const topicBottom = $("#topic-bottom").offset().top; const topicBottom = $("#topic-bottom").offset().top;
const $timeline = this.$(".timeline-container"); const timeline = this.element.querySelector(".timeline-container");
const timelineHeight = $timeline.height() || 400; const timelineHeight = (timeline && timeline.offsetHeight) || 400;
const footerHeight = $(".timeline-footer-controls").outerHeight(true) || 0; const footerHeight = $(".timeline-footer-controls").outerHeight(true) || 0;
const prev = this.dockAt; const prev = this.dockAt;

View File

@ -137,8 +137,8 @@ export default Ember.Component.extend(
return; return;
} }
const $this = this.$(); const thisElem = this.element;
if (!$this) { if (!thisElem) {
return; return;
} }
@ -146,7 +146,7 @@ export default Ember.Component.extend(
const bg = Ember.isEmpty(url) const bg = Ember.isEmpty(url)
? "" ? ""
: `url(${Discourse.getURLWithCDN(url)})`; : `url(${Discourse.getURLWithCDN(url)})`;
$this.css("background-image", bg); thisElem.style.backgroundImage = bg;
}, },
_showCallback(username, $target) { _showCallback(username, $target) {

View File

@ -30,8 +30,12 @@ export default Ember.Component.extend(LoadMore, {
$(window).on("resize.discourse-on-scroll", () => this.scrolled()); $(window).on("resize.discourse-on-scroll", () => this.scrolled());
this.$().on("click.details-disabled", "details.disabled", () => false); $(this.element).on(
this.$().on("click.discourse-redirect", ".excerpt a", function(e) { "click.details-disabled",
"details.disabled",
() => false
);
$(this.element).on("click.discourse-redirect", ".excerpt a", function(e) {
return ClickTrack.trackClick(e); return ClickTrack.trackClick(e);
}); });
}.on("didInsertElement"), }.on("didInsertElement"),
@ -40,10 +44,10 @@ export default Ember.Component.extend(LoadMore, {
_destroyed: function() { _destroyed: function() {
this.unbindScrolling("user-stream-view"); this.unbindScrolling("user-stream-view");
$(window).unbind("resize.discourse-on-scroll"); $(window).unbind("resize.discourse-on-scroll");
this.$().off("click.details-disabled", "details.disabled"); $(this.element).off("click.details-disabled", "details.disabled");
// Unbind link tracking // Unbind link tracking
this.$().off("click.discourse-redirect", ".excerpt a"); $(this.element).off("click.discourse-redirect", ".excerpt a");
}.on("willDestroyElement"), }.on("willDestroyElement"),
actions: { actions: {

View File

@ -962,7 +962,7 @@ function decorate(klass, evt, cb, id) {
const mixin = {}; const mixin = {};
mixin["_decorate_" + _decorateId++] = function($elem) { mixin["_decorate_" + _decorateId++] = function($elem) {
$elem = $elem || this.$(); $elem = $elem || $(this.element);
if ($elem) { if ($elem) {
cb($elem); cb($elem);
} }

View File

@ -405,11 +405,9 @@ const DiscourseURL = Ember.Object.extend({
@property router @property router
**/ **/
router: function() { get router() {
return Discourse.__container__.lookup("router:main"); return Discourse.__container__.lookup("router:main");
} },
.property()
.volatile(),
// Get a controller. Note that currently it uses `__container__` which is not // Get a controller. Note that currently it uses `__container__` which is not
// advised but there is no other way to access the router. // advised but there is no other way to access the router.

View File

@ -73,7 +73,7 @@ export default Ember.Mixin.create({
didInsertElement() { didInsertElement() {
this._super(...arguments); this._super(...arguments);
afterTransition(this.$(), this._hide.bind(this)); afterTransition($(this.element), this._hide.bind(this));
const id = this.elementId; const id = this.elementId;
const triggeringLinkClass = this.triggeringLinkClass; const triggeringLinkClass = this.triggeringLinkClass;
const clickOutsideEventName = `mousedown.outside-${id}`; const clickOutsideEventName = `mousedown.outside-${id}`;
@ -164,7 +164,7 @@ export default Ember.Mixin.create({
if (!target) { if (!target) {
return; return;
} }
const width = this.$().width(); const width = $(this.element).width();
const height = 175; const height = 175;
const isFixed = this.isFixed; const isFixed = this.isFixed;
const isDocked = this.isDocked; const isDocked = this.isDocked;
@ -227,7 +227,7 @@ export default Ember.Mixin.create({
position.top = avatarOverflowSize; position.top = avatarOverflowSize;
} }
this.$().css(position); $(this.element).css(position);
} }
} }
@ -236,23 +236,26 @@ export default Ember.Mixin.create({
let position = target.offset(); let position = target.offset();
position.top = "10%"; // match modal behaviour position.top = "10%"; // match modal behaviour
position.left = 0; position.left = 0;
this.$().css(position); $(this.element).css(position);
} }
this.$().toggleClass("docked-card", isDocked); $(this.element).toggleClass("docked-card", isDocked);
// After the card is shown, focus on the first link // After the card is shown, focus on the first link
// //
// note: we DO NOT use afterRender here cause _positionCard may // note: we DO NOT use afterRender here cause _positionCard may
// run afterwards, if we allowed this to happen the usercard // run afterwards, if we allowed this to happen the usercard
// may be offscreen and we may scroll all the way to it on focus // may be offscreen and we may scroll all the way to it on focus
Ember.run.next(null, () => this.$("a:first").focus()); Ember.run.next(null, () => {
const firstLink = this.element.querySelector("a");
firstLink && firstLink.focus();
});
} }
}); });
}, },
_hide() { _hide() {
if (!this.visible) { if (!this.visible) {
this.$().css({ left: -9999, top: -9999 }); $(this.element).css({ left: -9999, top: -9999 });
if (this.site.mobileView) { if (this.site.mobileView) {
$(".card-cloak").addClass("hidden"); $(".card-cloak").addClass("hidden");
} }

View File

@ -13,12 +13,12 @@ export default Ember.Mixin.create({
didInsertElement() { didInsertElement() {
this._super(...arguments); this._super(...arguments);
this.addTouchListeners(this.$()); this.addTouchListeners($(this.element));
}, },
willDestroyElement() { willDestroyElement() {
this._super(...arguments); this._super(...arguments);
this.removeTouchListeners(this.$()); this.removeTouchListeners($(this.element));
}, },
addTouchListeners($element) { addTouchListeners($element) {

View File

@ -36,7 +36,7 @@ export default Ember.Mixin.create({
}, },
_initialize: function() { _initialize: function() {
const $upload = this.$(); const $upload = $(this.element);
const reset = () => const reset = () =>
this.setProperties({ uploading: false, uploadProgress: 0 }); this.setProperties({ uploading: false, uploadProgress: 0 });
const maxFiles = this.getWithDefault( const maxFiles = this.getWithDefault(
@ -108,7 +108,7 @@ export default Ember.Mixin.create({
_destroy: function() { _destroy: function() {
this.messageBus && this.messageBus.unsubscribe("/uploads/" + this.type); this.messageBus && this.messageBus.unsubscribe("/uploads/" + this.type);
const $upload = this.$(); const $upload = $(this.element);
try { try {
$upload.fileupload("destroy"); $upload.fileupload("destroy");
} catch (e) { } catch (e) {

View File

@ -57,7 +57,9 @@ export default ComboBoxSelectBoxHeaderComponent.extend({
didRender() { didRender() {
this._super(...arguments); this._super(...arguments);
this.$().attr("style", this.categoryStyle); this.element.setAttribute("style", this.categoryStyle);
this.$(".caret-icon").attr("style", this.categoryStyle); this.element
.querySelector(".caret-icon")
.setAttribute("style", this.categoryStyle);
} }
}); });

View File

@ -54,7 +54,7 @@ export default ComboBox.extend(TagsMixin, {
didInsertElement() { didInsertElement() {
this._super(...arguments); this._super(...arguments);
this.$(".select-kit-body").on( $(this.element.querySelector(".select-kit-body")).on(
"mousedown touchstart", "mousedown touchstart",
".selected-tag", ".selected-tag",
event => { event => {
@ -68,7 +68,9 @@ export default ComboBox.extend(TagsMixin, {
willDestroyElement() { willDestroyElement() {
this._super(...arguments); this._super(...arguments);
this.$(".select-kit-body").off("mousedown touchstart"); $(this.element.querySelector(".select-kit-body")).off(
"mousedown touchstart"
);
}, },
@computed("hasReachedMaximum") @computed("hasReachedMaximum")

View File

@ -40,7 +40,7 @@ export default SelectKitComponent.extend({
_setChoicesMaxWidth() { _setChoicesMaxWidth() {
const width = this.$body().outerWidth(false); const width = this.$body().outerWidth(false);
if (width > 0) { if (width > 0) {
this.$(".choices").css({ maxWidth: width }); this.element.querySelector(".choices").style.maxWidth = `${width}px`;
} }
}, },

View File

@ -24,13 +24,13 @@ export default SelectKitHeaderComponent.extend({
_positionFilter() { _positionFilter() {
if (!this.shouldDisplayFilter) return; if (!this.shouldDisplayFilter) return;
const $filter = this.$(".filter"); const $filter = $(this.element.querySelector(".filter"));
$filter.width(0); $filter.width(0);
const leftHeaderOffset = this.$().offset().left; const leftHeaderOffset = $(this.element).offset().left;
const leftFilterOffset = $filter.offset().left; const leftFilterOffset = $filter.offset().left;
const offset = leftFilterOffset - leftHeaderOffset; const offset = leftFilterOffset - leftHeaderOffset;
const width = this.$().outerWidth(false); const width = $(this.element).outerWidth(false);
const availableSpace = width - offset; const availableSpace = width - offset;
const $choices = $filter.parent(".choices"); const $choices = $filter.parent(".choices");
const parentRightPadding = parseInt($choices.css("padding-right"), 10); const parentRightPadding = parseInt($choices.css("padding-right"), 10);

View File

@ -18,23 +18,27 @@ export default Ember.Mixin.create({
}, },
$findRowByValue(value) { $findRowByValue(value) {
return this.$(`${this.rowSelector}[data-value='${value}']`); return $(
this.element.querySelector(`${this.rowSelector}[data-value='${value}']`)
);
}, },
$header() { $header() {
return this.$(this.headerSelector); return $(this.element && this.element.querySelector(this.headerSelector));
}, },
$body() { $body() {
return this.$(this.bodySelector); return $(this.element && this.element.querySelector(this.bodySelector));
}, },
$wrapper() { $wrapper() {
return this.$(this.wrapperSelector); return $(this.element && this.element.querySelector(this.wrapperSelector));
}, },
$collection() { $collection() {
return this.$(this.collectionSelector); return $(
this.element && this.element.querySelector(this.collectionSelector)
);
}, },
$scrollableParent() { $scrollableParent() {
@ -58,7 +62,9 @@ export default Ember.Mixin.create({
}, },
$filterInput() { $filterInput() {
return this.$(this.filterInputSelector); return $(
this.element && this.element.querySelector(this.filterInputSelector)
);
}, },
_adjustPosition() { _adjustPosition() {
@ -180,7 +186,8 @@ export default Ember.Mixin.create({
if (this.fullWidthOnMobile && (this.site && this.site.isMobileDevice)) { if (this.fullWidthOnMobile && (this.site && this.site.isMobileDevice)) {
const margin = 10; const margin = 10;
const relativeLeft = this.$().offset().left - $(window).scrollLeft(); const relativeLeft =
$(this.element).offset().left - $(window).scrollLeft();
options.left = margin - relativeLeft; options.left = margin - relativeLeft;
options.width = windowWidth - margin * 2; options.width = windowWidth - margin * 2;
options.maxWidth = options.minWidth = "unset"; options.maxWidth = options.minWidth = "unset";
@ -193,7 +200,8 @@ export default Ember.Mixin.create({
let spaceToLeftEdge; let spaceToLeftEdge;
if (this.$scrollableParent().length) { if (this.$scrollableParent().length) {
spaceToLeftEdge = spaceToLeftEdge =
this.$().offset().left - this.$scrollableParent().offset().left; $(this.element).offset().left -
this.$scrollableParent().offset().left;
} else { } else {
spaceToLeftEdge = this.element.getBoundingClientRect().left; spaceToLeftEdge = this.element.getBoundingClientRect().left;
} }
@ -206,9 +214,8 @@ export default Ember.Mixin.create({
} }
if (isLeftAligned) { if (isLeftAligned) {
this.$() this.element.classList.add("is-left-aligned");
.addClass("is-left-aligned") this.element.classList.remove("is-right-aligned");
.removeClass("is-right-aligned");
if (this._isRTL()) { if (this._isRTL()) {
options.right = this.horizontalOffset; options.right = this.horizontalOffset;
@ -216,9 +223,8 @@ export default Ember.Mixin.create({
options.left = -bodyWidth + elementWidth - this.horizontalOffset; options.left = -bodyWidth + elementWidth - this.horizontalOffset;
} }
} else { } else {
this.$() this.element.classList.add("is-right-aligned");
.addClass("is-right-aligned") this.element.classList.remove("is-left-aligned");
.removeClass("is-left-aligned");
if (this._isRTL()) { if (this._isRTL()) {
options.right = -bodyWidth + elementWidth - this.horizontalOffset; options.right = -bodyWidth + elementWidth - this.horizontalOffset;
@ -234,14 +240,12 @@ export default Ember.Mixin.create({
const headerHeight = this._computedStyle(this.$header()[0], "height"); const headerHeight = this._computedStyle(this.$header()[0], "height");
if (hasBelowSpace || (!hasBelowSpace && !hasAboveSpace)) { if (hasBelowSpace || (!hasBelowSpace && !hasAboveSpace)) {
this.$() this.element.classList.add("is-below");
.addClass("is-below") this.element.classList.remove("is-above");
.removeClass("is-above");
options.top = headerHeight + this.verticalOffset; options.top = headerHeight + this.verticalOffset;
} else { } else {
this.$() this.element.classList.add("is-above");
.addClass("is-above") this.element.classList.remove("is-below");
.removeClass("is-below");
options.bottom = headerHeight + this.verticalOffset; options.bottom = headerHeight + this.verticalOffset;
} }
@ -262,13 +266,13 @@ export default Ember.Mixin.create({
this._previousCSSContext = this._previousCSSContext || { this._previousCSSContext = this._previousCSSContext || {
width, width,
minWidth: this.$().css("min-width"), minWidth: this.element.style.minWidth,
maxWidth: this.$().css("max-width"), maxWidth: this.element.style.maxWidth,
top: this.$().css("top"), top: this.element.style.top,
left: this.$().css("left"), left: this.element.style.left,
marginLeft: this.$().css("margin-left"), marginLeft: this.element.style.marginLeft,
marginRight: this.$().css("margin-right"), marginRight: this.element.style.marginRight,
position: this.$().css("position") position: this.element.style.position
}; };
const componentStyles = { const componentStyles = {
@ -289,11 +293,11 @@ export default Ember.Mixin.create({
display: "inline-block", display: "inline-block",
width, width,
height, height,
"margin-bottom": this.$().css("margin-bottom"), "margin-bottom": this.element.style.marginBottom,
"vertical-align": "middle" "vertical-align": "middle"
}); });
this.$() $(this.element)
.before($placeholderTemplate) .before($placeholderTemplate)
.css(componentStyles); .css(componentStyles);
@ -306,7 +310,7 @@ export default Ember.Mixin.create({
if (!this.element || this.isDestroying || this.isDestroyed) return; if (!this.element || this.isDestroying || this.isDestroyed) return;
if (this.$scrollableParent().length === 0) return; if (this.$scrollableParent().length === 0) return;
this.$().css(this._previousCSSContext || {}); $(this.element).css(this._previousCSSContext || {});
this.$scrollableParent().css( this.$scrollableParent().css(
"overflow", "overflow",
this._previousScrollParentOverflow || {} this._previousScrollParentOverflow || {}

View File

@ -82,7 +82,7 @@ export default Ember.Mixin.create({
return true; return true;
} }
if (Ember.$.contains(this.element, event.target)) { if (this.element !== event.target && this.element.contains(event.target)) {
event.stopPropagation(); event.stopPropagation();
if (!this.renderedBodyOnce) return; if (!this.renderedBodyOnce) return;
if (!this.isFocused) return; if (!this.isFocused) return;
@ -398,7 +398,12 @@ export default Ember.Mixin.create({
}, },
onFilterInputFocusout(event) { onFilterInputFocusout(event) {
if (!Ember.$.contains(this.element, event.relatedTarget)) { if (
!(
this.element !== event.relatedTarget &&
this.element.contains(event.relatedTarget)
)
) {
this.close(event); this.close(event);
} }
}, },

View File

@ -59,7 +59,7 @@ export default Ember.Component.extend({
this.set("inviteEmail", ""); this.set("inviteEmail", "");
Ember.run.scheduleOnce("afterRender", () => Ember.run.scheduleOnce("afterRender", () =>
this.$(".invite-email").focus() this.element.querySelector(".invite-email").focus()
); );
}, },

View File

@ -12,6 +12,8 @@ export default Ember.Component.extend({
@on("init") @on("init")
updateVal() { updateVal() {
const checked = this.value === this.radioValue; const checked = this.value === this.radioValue;
Ember.run.next(() => this.$("input[type=radio]").prop("checked", checked)); Ember.run.next(
() => (this.element.querySelector("input[type=radio]").checked = checked)
);
} }
}); });

View File

@ -62,7 +62,7 @@ export default Ember.Component.extend({
didInsertElement() { didInsertElement() {
this._super(...arguments); this._super(...arguments);
const canvas = this.$()[0]; const canvas = this.element;
this.ctx = canvas.getContext("2d"); this.ctx = canvas.getContext("2d");
this.resized(); this.resized();
@ -86,7 +86,7 @@ export default Ember.Component.extend({
width = $(window).width(); width = $(window).width();
height = $(window).height(); height = $(window).height();
const canvas = this.$()[0]; const canvas = this.element;
canvas.width = width; canvas.width = width;
canvas.height = height; canvas.height = height;
}, },

View File

@ -17,7 +17,7 @@ export default Ember.Component.extend({
didInsertElement() { didInsertElement() {
this._super(...arguments); this._super(...arguments);
const $upload = this.$(); const $upload = $(this.element);
const id = this.get("field.id"); const id = this.get("field.id");

View File

@ -43,7 +43,7 @@ export function createPreviewComponent(width, height, obj) {
didInsertElement() { didInsertElement() {
this._super(...arguments); this._super(...arguments);
const c = this.$("canvas")[0]; const c = this.element.querySelector("canvas");
this.ctx = c.getContext("2d"); this.ctx = c.getContext("2d");
this.ctx.scale(scale, scale); this.ctx.scale(scale, scale);
this.reload(); this.reload();

View File

@ -64,7 +64,7 @@ class ThemeField < ActiveRecord::Base
validates :name, format: { with: /\A[a-z_][a-z0-9_-]*\z/i }, validates :name, format: { with: /\A[a-z_][a-z0-9_-]*\z/i },
if: Proc.new { |field| ThemeField.theme_var_type_ids.include?(field.type_id) } if: Proc.new { |field| ThemeField.theme_var_type_ids.include?(field.type_id) }
BASE_COMPILER_VERSION = 11 BASE_COMPILER_VERSION = 12
DEPENDENT_CONSTANTS = [BASE_COMPILER_VERSION, DEPENDENT_CONSTANTS = [BASE_COMPILER_VERSION,
GlobalSetting.cdn_url] GlobalSetting.cdn_url]
COMPILER_VERSION = Digest::SHA1.hexdigest(DEPENDENT_CONSTANTS.join) COMPILER_VERSION = Digest::SHA1.hexdigest(DEPENDENT_CONSTANTS.join)

View File

@ -13,6 +13,7 @@ class ThemeJavascriptCompiler
// Helper to replace old themeSetting syntax // Helper to replace old themeSetting syntax
function generateHelper(settingParts) { function generateHelper(settingParts) {
console.log(settingParts)
const settingName = settingParts.join('.'); const settingName = settingParts.join('.');
return { return {
"path": { "path": {
@ -64,7 +65,7 @@ class ThemeJavascriptCompiler
} }
function manipulateNode(node) { function manipulateNode(node) {
// Magically add theme id as the first param for each of these helpers // Magically add theme id as the first param for each of these helpers)
if (node.path.parts && ["theme-i18n", "theme-prefix", "theme-setting"].includes(node.path.parts[0])) { if (node.path.parts && ["theme-i18n", "theme-prefix", "theme-setting"].includes(node.path.parts[0])) {
if(node.params.length === 1){ if(node.params.length === 1){
node.params.unshift({ node.params.unshift({
@ -134,10 +135,16 @@ class ThemeJavascriptCompiler
def discourse_extension def discourse_extension
<<~JS <<~JS
Ember.HTMLBars.registerPlugin('ast', function(){ Ember.HTMLBars.registerPlugin('ast', function() {
return { name: 'theme-template-manipulator', return {
visitor: { SubExpression: manipulateNode, MustacheStatement: manipulateNode, PathExpression: manipulatePath} name: 'theme-template-manipulator',
}}); visitor: {
SubExpression: manipulateNode,
MustacheStatement: manipulateNode,
PathExpression: manipulatePath
}
}
});
JS JS
end end
end end

View File

@ -84,26 +84,28 @@ describe ThemeJavascriptCompiler do
block["statements"] block["statements"]
end end
# might change/break when updating ember
EMBER_INTERNAL_ID = 29
it 'adds the theme id to the helpers' do it 'adds the theme id to the helpers' do
expect(statement("{{theme-prefix 'translation_key'}}")). expect(statement("{{theme-prefix 'translation_key'}}")).
to eq([[1, [27, "theme-prefix", [22, "translation_key"], nil], false]]) to eq([[1, [EMBER_INTERNAL_ID, "theme-prefix", [22, "translation_key"], nil], false]])
expect(statement("{{theme-i18n 'translation_key'}}")). expect(statement("{{theme-i18n 'translation_key'}}")).
to eq([[1, [27, "theme-i18n", [22, "translation_key"], nil], false]]) to eq([[1, [EMBER_INTERNAL_ID, "theme-i18n", [22, "translation_key"], nil], false]])
expect(statement("{{theme-setting 'setting_key'}}")). expect(statement("{{theme-setting 'setting_key'}}")).
to eq([[1, [27, "theme-setting", [22, "setting_key"], nil], false]]) to eq([[1, [EMBER_INTERNAL_ID, "theme-setting", [22, "setting_key"], nil], false]])
# Works when used inside other statements # Works when used inside other statements
expect(statement("{{dummy-helper (theme-prefix 'translation_key')}}")). expect(statement("{{dummy-helper (theme-prefix 'translation_key')}}")).
to eq([[1, [27, "dummy-helper", [[27, "theme-prefix", [22, "translation_key"], nil]], nil], false]]) to eq([[1, [EMBER_INTERNAL_ID, "dummy-helper", [[EMBER_INTERNAL_ID, "theme-prefix", [22, "translation_key"], nil]], nil], false]])
end end
it 'works with the old settings syntax' do it 'works with the old settings syntax' do
expect(statement("{{themeSettings.setting_key}}")). expect(statement("{{themeSettings.setting_key}}")).
to eq([[1, [27, "theme-setting", [22, "setting_key"], [["deprecated"], [true]]], false]]) to eq([[1, [EMBER_INTERNAL_ID, "theme-setting", [22, "setting_key"], [["deprecated"], [true]]], false]])
# Works when used inside other statements # Works when used inside other statements
expect(statement("{{dummy-helper themeSettings.setting_key}}")). expect(statement("{{dummy-helper themeSettings.setting_key}}")).
to eq([[1, [27, "dummy-helper", [[27, "theme-setting", [22, "setting_key"], [["deprecated"], [true]]]], nil], false]]) to eq([[1, [EMBER_INTERNAL_ID, "dummy-helper", [[EMBER_INTERNAL_ID, "theme-setting", [22, "setting_key"], [["deprecated"], [true]]]], nil], false]])
end end
end end