@ima/core
Version:
IMA.js framework for isomorphic javascript application
122 lines (121 loc) • 2.71 kB
JavaScript
import { MetaManager } from './MetaManager';
/**
* Default implementation of the {@link MetaManager} interface.
*/ export class MetaManagerImpl extends MetaManager {
_title;
_metaName;
_metaProperty;
_link;
static get $dependencies() {
return [];
}
/**
* Initializes the meta page attributes manager.
*/ constructor(){
super();
/**
* The page title.
*/ this._title = '';
/**
* Storage of generic meta information.
*/ this._metaName = new Map();
/**
* Storage of specialized meta information.
*/ this._metaProperty = new Map();
/**
* Storage of generic link information.
*/ this._link = new Map();
}
/**
* @inheritDoc
*/ setTitle(title) {
this._title = title;
return this;
}
/**
* @inheritDoc
*/ getTitle() {
return this._title;
}
/**
* @inheritDoc
*/ setMetaName(name, content, attr) {
this._metaName.set(name, {
content,
...attr
});
return this;
}
/**
* @inheritDoc
*/ getMetaName(name) {
return this._metaName.get(name) || super.getMetaName(name);
}
/**
* @inheritDoc
*/ getMetaNames() {
return Array.from(this._metaName.keys());
}
/**
* @inheritDoc
*/ getMetaNamesIterator() {
return this._metaName.entries();
}
/**
* @inheritDoc
*/ setMetaProperty(property, content, attr) {
this._metaProperty.set(property, {
content,
...attr
});
return this;
}
/**
* @inheritDoc
*/ getMetaProperty(property) {
return this._metaProperty.get(property) || super.getMetaProperty(property);
}
/**
* @inheritDoc
*/ getMetaProperties() {
return Array.from(this._metaProperty.keys());
}
/**
* @inheritDoc
*/ getMetaPropertiesIterator() {
return this._metaProperty.entries();
}
/**
* @inheritDoc
*/ setLink(relation, href, attr) {
this._link.set(relation, {
href,
...attr
});
return this;
}
/**
* @inheritDoc
*/ getLink(relation) {
return this._link.get(relation) || super.getLink(relation);
}
/**
* @inheritDoc
*/ getLinks() {
return Array.from(this._link.keys());
}
/**
* @inheritDoc
*/ getLinksIterator() {
return this._link.entries();
}
/**
* @inheritdoc
*/ clearMetaAttributes() {
this._title = '';
this._metaProperty.clear();
this._metaName.clear();
this._link.clear();
}
}
//# sourceMappingURL=MetaManagerImpl.js.map