Skip to content

Commit

Permalink
A child class that's not supposed to run the parents constructor? Tha…
Browse files Browse the repository at this point in the history
…t needs a workaround in es6 classes.
  • Loading branch information
TuxedoTako committed Mar 4, 2023
1 parent 97d9090 commit 96a2c7b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/classes/Post.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import $ from "../platform/$";
import $$ from "../platform/$$";
import Callbacks from "./Callbacks";

/**
* Original coffeescript version added a child class that somehow skips the original constructor in the compilation
* output? In es classes we have to do tha manually.
*/
const skipConstructor = Symbol('skip post constructor');

/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
Expand All @@ -27,6 +33,8 @@ export default class Post {
// @normalizedOriginal = Test.normalize root
// <% } %>

if (root === skipConstructor) return;

this.root = root;
this.thread = thread;
this.board = board;
Expand Down Expand Up @@ -347,7 +355,7 @@ export default class Post {
addClone(context, contractThumb) {
// Callbacks may not have been run yet due to anti-browser-lock delay in Main.callbackNodesDB.
Callbacks.Post.execute(this);
return new PostClone(this.root, this.thread, this.board, this.flags).construct(this, context, contractThumb);
return new PostClone(skipConstructor).construct(this, context, contractThumb);
}

rmClone(index) {
Expand Down

0 comments on commit 96a2c7b

Please sign in to comment.