* Tag the binding with names or name/value objects. A tag has a name and * an optional value. If not supplied, the tag name is used as the value. * * @param tags - A list of names or name/value objects. Each * parameter can be in one of the following forms: * - string: A tag name with
(...tags: BindingTag[])
| 666 | * ``` |
| 667 | */ |
| 668 | tag(...tags: BindingTag[]): this { |
| 669 | for (const t of tags) { |
| 670 | if (typeof t === 'string') { |
| 671 | this.tagMap[t] = t; |
| 672 | } else if (Array.isArray(t)) { |
| 673 | // Throw an error as TypeScript cannot exclude array from TagMap |
| 674 | throw new Error( |
| 675 | 'Tag must be a string or an object (but not array): ' + t, |
| 676 | ); |
| 677 | } else { |
| 678 | Object.assign(this.tagMap, t); |
| 679 | } |
| 680 | } |
| 681 | this.emitChangedEvent('tag'); |
| 682 | return this; |
| 683 | } |
| 684 | |
| 685 | /** |
| 686 | * Get an array of tag names |