mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-14 10:43:24 +00:00
Bug 1573473 - Creates global function to make strings kebab-case. r=johannh
Differential Revision: https://phabricator.services.mozilla.com/D41818 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
3660d8e202
commit
7a290c37fd
@ -3,6 +3,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import { InfoItem } from "./info-item.js";
|
||||
import { normalizeToKebabCase } from "../utils.js";
|
||||
|
||||
export class InfoGroup extends HTMLElement {
|
||||
constructor(item) {
|
||||
@ -24,9 +25,7 @@ export class InfoGroup extends HTMLElement {
|
||||
|
||||
// Adds a class with the section title's name, to make
|
||||
// it easier to find when highlighting errors.
|
||||
this.classList.add(
|
||||
this.item.sectionTitle.replace(/\s+/g, "-").toLowerCase()
|
||||
);
|
||||
this.classList.add(normalizeToKebabCase(this.item.sectionTitle));
|
||||
|
||||
for (let i = 0; i < this.item.sectionItems.length; i++) {
|
||||
this.shadowRoot.append(new InfoItem(this.item.sectionItems[i]));
|
||||
|
@ -2,6 +2,8 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import { normalizeToKebabCase } from "../utils.js";
|
||||
|
||||
export class InfoItem extends HTMLElement {
|
||||
constructor(item) {
|
||||
super();
|
||||
@ -23,12 +25,7 @@ export class InfoItem extends HTMLElement {
|
||||
|
||||
render() {
|
||||
let label = this.shadowRoot.querySelector("label");
|
||||
let labelText = this.item.label
|
||||
.replace(/\s+/g, "-")
|
||||
.replace(/\./g, "")
|
||||
.replace(/\//g, "")
|
||||
.replace(/--/g, "-")
|
||||
.toLowerCase();
|
||||
let labelText = normalizeToKebabCase(this.item.label);
|
||||
label.setAttribute("data-l10n-id", "certificate-viewer-" + labelText);
|
||||
|
||||
this.classList.add(labelText);
|
||||
|
@ -57,3 +57,14 @@ export const hashify = hash => {
|
||||
export const pemToDER = pem => {
|
||||
return stringToArrayBuffer(window.atob(pem));
|
||||
};
|
||||
|
||||
export const normalizeToKebabCase = string => {
|
||||
let kebabString = string
|
||||
.replace(/\s+/g, "-")
|
||||
.replace(/\./g, "")
|
||||
.replace(/\//g, "")
|
||||
.replace(/--/g, "-")
|
||||
.toLowerCase();
|
||||
|
||||
return kebabString;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user