Skip to content

Commit e47a557

Browse files
committed
Merge branch 'release/latest'
2 parents 9447c8e + 8e6a1c5 commit e47a557

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@microsoft/mgt",
3-
"version": "1.2.4",
3+
"version": "1.2.5",
44
"description": "The Microsoft Graph Toolkit",
55
"keywords": [
66
"microsoft graph",

src/components/mgt-person/mgt-person.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,8 +748,7 @@ export class MgtPerson extends MgtTemplatedComponent {
748748
if (!initials && person.displayName) {
749749
const name = person.displayName.split(/\s+/);
750750
for (let i = 0; i < 2 && i < name.length; i++) {
751-
if (name[i][0] && name[i][0].match(/\p{L}/gu)) {
752-
// check if letter
751+
if (name[i][0] && this.isLetter(name[i][0])) {
753752
initials += name[i][0].toUpperCase();
754753
}
755754
}
@@ -758,6 +757,14 @@ export class MgtPerson extends MgtTemplatedComponent {
758757
return initials;
759758
}
760759

760+
private isLetter(char: string) {
761+
try {
762+
return char.match(new RegExp('\\p{L}', 'u'));
763+
} catch (e) {
764+
return char.toLowerCase() !== char.toUpperCase();
765+
}
766+
}
767+
761768
private handleMouseClick(e: MouseEvent) {
762769
if (this.personCardInteraction === PersonCardInteraction.click) {
763770
this.showPersonCard();

src/components/templateHelper.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class TemplateHelper {
5050
const div = document.createElement('div');
5151
// tslint:disable-next-line: prefer-for-of
5252
for (let i = 0; i < template.childNodes.length; i++) {
53-
div.appendChild(template.childNodes[i].cloneNode(true));
53+
div.appendChild(this.simpleCloneNode(template.childNodes[i]));
5454
}
5555
rendered = this.renderNode(div, root, context, additionalContext);
5656
}
@@ -62,6 +62,26 @@ export class TemplateHelper {
6262

6363
private static _expression = /{{+\s*[$\w\.()\[\]]+\s*}}+/g;
6464

65+
// simple implementation of deep cloneNode
66+
// required for nested templates in polyfilled browsers
67+
private static simpleCloneNode(node: ChildNode) {
68+
if (!node) {
69+
return null;
70+
}
71+
72+
const clone = node.cloneNode(false);
73+
74+
// tslint:disable-next-line:prefer-for-of
75+
for (let i = 0; i < node.childNodes.length; i++) {
76+
const childClone = this.simpleCloneNode(node.childNodes[i]);
77+
if (childClone) {
78+
clone.appendChild(childClone);
79+
}
80+
}
81+
82+
return clone;
83+
}
84+
6585
private static expandExpressionsAsString(str: string, context: object, additionalContext: object) {
6686
return str.replace(this._expression, match => {
6787
const value = this.evalInContext(this.trimExpression(match), { ...context, ...additionalContext });

src/utils/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
// THIS FILE IS AUTO GENERATED
99
// ANY CHANGES WILL BE LOST DURING BUILD
1010

11-
export const PACKAGE_VERSION = '1.2.4';
11+
export const PACKAGE_VERSION = '1.2.5';

0 commit comments

Comments
 (0)