File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -15,9 +15,15 @@ A simple and easy JavaScript library for highlighting .NET stack traces
15
15
[ Stack Trace Formatter - Online pretty print of .NET stack traces] ( https://elmah.io/tools/stack-trace-formatter/ )
16
16
17
17
#### Initialization
18
+ Using a string that represents a CSS selector:
18
19
``` javascript
19
20
const stack = new netStack (' .stacktrace' );
20
21
```
22
+ Passing an HTMLElement object:
23
+ ``` javascript
24
+ const stackElement = document .querySelector (' .stacktrace' );
25
+ const stack = new netStack (stackElement);
26
+ ```
21
27
22
28
#### Default values for classes
23
29
``` javascript
Original file line number Diff line number Diff line change 20
20
21
21
function netStack ( element , options ) {
22
22
if ( typeof document !== 'undefined' ) {
23
- this . element = document . querySelector ( element ) ;
23
+ if ( typeof element === 'string' ) {
24
+ this . element = document . querySelector ( element ) ;
25
+ } else if ( element instanceof HTMLElement ) {
26
+ this . element = element ;
27
+ } else {
28
+ throw new Error ( 'The element parameter must be a selector string or an HTMLElement.' ) ;
29
+ }
24
30
} else {
25
31
throw new Error ( 'netStack requires a DOM environment' ) ;
26
32
}
You can’t perform that action at this time.
0 commit comments