Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
scofalik committed Aug 8, 2019
1 parent 66fb53b commit 3f44aa0
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions src/conversion/mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default class Mapper {
*/
this._markerNameToElements = new Map();

this._elementToMarkerName = new Map();
this._elementToMarkerNames = new Map();

this.markersToRefresh = new Set();

Expand Down Expand Up @@ -136,8 +136,10 @@ export default class Mapper {

this._viewToModelMapping.delete( viewElement );

if ( this._elementToMarkerName.has( viewElement ) ) {
this.markersToRefresh.add( this._elementToMarkerName.get( viewElement ) );
if ( this._elementToMarkerNames.has( viewElement ) ) {
for ( const markerName of this._elementToMarkerNames.get( viewElement ) ) {
this.markersToRefresh.add( markerName );
}
}

if ( this._modelToViewMapping.get( modelElement ) == viewElement ) {
Expand Down Expand Up @@ -175,11 +177,13 @@ export default class Mapper {
*/
bindElementToMarker( element, name ) {
const elements = this._markerNameToElements.get( name ) || new Set();

elements.add( element );

const names = this._elementToMarkerNames.get( element ) || new Set();
names.add( name );

this._markerNameToElements.set( name, elements );
this._elementToMarkerName.set( element, name );
this._elementToMarkerNames.set( element, names );
}

/**
Expand All @@ -194,12 +198,20 @@ export default class Mapper {
if ( elements ) {
elements.delete( element );

this._elementToMarkerName.delete( element );

if ( elements.size == 0 ) {
this._markerNameToElements.delete( name );
}
}

const names = this._elementToMarkerNames.get( element );

if ( names ) {
names.delete( name );

if ( name.size == 0 ) {
this._elementToMarkerNames.delete( element );
}
}
}

/**
Expand All @@ -209,7 +221,7 @@ export default class Mapper {
this._modelToViewMapping = new WeakMap();
this._viewToModelMapping = new WeakMap();
this._markerNameToElements = new Map();
this._elementToMarkerName = new Map();
this._elementToMarkerNames = new Map();
}

/**
Expand Down

0 comments on commit 3f44aa0

Please sign in to comment.