• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bindable-ui / bindable / 5404453632

pending completion
5404453632

push

github

web-flow
Merge pull request #159 from bindable-ui/mj/prefixIcon

prefixIcon related changes

587 of 1013 branches covered (57.95%)

Branch coverage included in aggregate %.

2867 of 3558 relevant lines covered (80.58%)

55.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.94
/src/components/type/code-sample/c-code-sample.ts
1
/*
2
© 2022 Edgecast Inc.
3
Licensed under the terms of the MIT license. See the LICENSE file in the project root for license terms.
4
*/
5

6
import {child, processContent} from 'aurelia-framework';
88✔
7

8
const MAX_RENDER_RETRIES = 25;
88✔
9
const RETRY_TIMEOUT = 5;
88✔
10

11
@processContent((_compiler, _resources, node) => {
12
    const originalHtml = node.innerHTML;
2✔
13
    const stringified = JSON.stringify(originalHtml);
2✔
14
    node.innerHTML = `<code-sample data.bind='${stringified}'></code-sample>`;
2✔
15
    node.innerHTML += `<template replace-part="rendered">${originalHtml}</template>`;
2✔
16
    return true;
2✔
17
})
18
export class CCodeSample {
88✔
19
    @child('code-sample')
20
    public codeSample;
88✔
21
    public renderTries = 0;
2✔
22
    public code;
23

24
    public attached() {
88✔
25
        this.render();
2✔
26
    }
27

28
    public render() {
88✔
29
        this.renderTries += 1;
43✔
30

31
        try {
43✔
32
            this.code = this.codeSample.data;
43✔
33
            this.trimCode();
×
34
        } catch (err) {
35
            if (this.renderTries < MAX_RENDER_RETRIES) {
43✔
36
                setTimeout(() => {
16✔
37
                    this.render();
15✔
38
                }, RETRY_TIMEOUT);
39
            }
40
        }
41
    }
42

43
    public trimCode() {
88✔
44
        // take the number of leading spaces on the first line of code and remove them from each
45
        // line of code.
46
        const regex = /^\n(\s+)/;
1✔
47
        const res = this.code.match(regex) || '';
1!
48
        if (res.length > 1) {
1✔
49
            const spaces = res[1];
1✔
50
            const replaceRegex = new RegExp(`(\n)${spaces}`, 'g');
1✔
51
            this.code = this.code.replace(replaceRegex, '$1').trim();
1✔
52
        }
53
    }
54
}
88✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc