Skip to content

In current Markers extensions class, we're comparing JS objects with '==='. And this result in errors removing markers with accuracy. #155

@KhozmoS

Description

@KhozmoS

current class

class Marker {
    constructor(square, type) {
        this.square = square
        this.type = type
    }

    matches(square = undefined, type = undefined) {
        if (!type && !square) {
            return true
        } else if (!type) {
            if (square === this.square) {
                return true
            }
        } else if (!square) {
            if (this.type === type) {
                return true
            }
        } else if (this.type === type && square === this.square) {
            return true
        }
        return false
    }
}

suggested change:

class Marker {
    constructor(square, type) {
        this.square = square
        this.type = type
    }

    matches(square = undefined, type = undefined) {
        if (!type && !square) {
            return true
        } else if (!type) {
            if (square === this.square) {
                return true
            }
        } else if (!square) {
            if (JSON.stringify(this.type) === JSON.stringify(type)) {
                return true
            }
        } else if (JSON.stringify(this.type) === JSON.stringify(type) && square === this.square) {
            return true
        }
        return false
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions