Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Td/class syntax #21325

Draft
wants to merge 12 commits into
base: trunk
Choose a base branch
from
Prev Previous commit
Next Next commit
Explicitly make parse method static. This way this method can only be…
… accessed from the Class itself and not from the object instance of the class.
  • Loading branch information
FAMarfuaty authored and mhkuu committed Apr 17, 2024
commit 386cc38ccf9ae2289043aaff64079585540f8674
2 changes: 1 addition & 1 deletion packages/yoastseo/src/languageProcessing/values/Clause.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class Clause {
*
* @returns {Clause} The parsed Clause.
*/
parse( serialized ) {
static parse( serialized ) {
const clause = new Clause( serialized.clauseText, serialized.auxiliaries );
clause.setPassive( serialized.isPassive );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class ProminentWord {
*
* @returns {ProminentWord} The parsed ProminentWord.
*/
parse( serialized ) {
static parse( serialized ) {
return new ProminentWord( serialized.word, serialized.stem, serialized.occurrences );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class Sentence {
*
* @returns {Sentence} The parsed Sentence.
*/
parse( serialized ) {
static parse( serialized ) {
const sentence = new Sentence( serialized.sentenceText );
sentence.setClauses( serialized.clauses );
sentence.setPassive( serialized.isPassive );
Expand Down
2 changes: 1 addition & 1 deletion packages/yoastseo/src/values/AssessmentResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class AssessmentResult {
*
* @returns {AssessmentResult} The parsed AssessmentResult.
*/
parse( serialized ) {
static parse( serialized ) {
const result = new AssessmentResult( {
text: serialized.text,
score: serialized.score,
Expand Down
2 changes: 1 addition & 1 deletion packages/yoastseo/src/values/Mark.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class Mark {
*
* @returns {Mark} The parsed Mark.
*/
parse( serialized ) {
static parse( serialized ) {
delete serialized._parseClass;
return new Mark( serialized );
}
Expand Down
2 changes: 1 addition & 1 deletion packages/yoastseo/src/values/Paper.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ class Paper {
*
* @returns {Paper} The parsed Paper.
*/
parse( serialized ) {
static parse( serialized ) {
// For ease of use, check if it is not already a Paper instance.
if ( serialized instanceof Paper ) {
return serialized;
Expand Down
2 changes: 1 addition & 1 deletion packages/yoastseo/src/worker/AnalysisWebWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ export default class AnalysisWebWorker {
return await Promise.all( keywordKeys.map( key => {
this._relatedKeywords[ key ] = relatedKeywords[ key ];

const relatedPaper = Paper.prototype.parse( {
const relatedPaper = Paper.parse( {
...paper.serialize(),
keyword: this._relatedKeywords[ key ].keyword,
synonyms: this._relatedKeywords[ key ].synonyms,
Expand Down
2 changes: 1 addition & 1 deletion packages/yoastseo/src/worker/transporter/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function parse( thing ) {
const thingIsObject = isObject( thing );

if ( thingIsObject && thing._parseClass && PARSE_CLASSES[ thing._parseClass ] ) {
return PARSE_CLASSES[ thing._parseClass ].prototype.parse( thing );
return PARSE_CLASSES[ thing._parseClass ].parse( thing );
}

if ( thingIsObject ) {
Expand Down