Skip to content

Commit

Permalink
fix: attempt to activate the first app frame
Browse files Browse the repository at this point in the history
Closes: #48
  • Loading branch information
thetutlage committed Sep 6, 2023
1 parent 56bf9f3 commit 2fdcded
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/Youch.js
Expand Up @@ -15,6 +15,7 @@ const cookie = require('cookie')
const Mustache = require('mustache')
const { fileURLToPath } = require('url')
const StackTracey = require('stacktracey')
const { serialize } = require('v8')
const VIEW_PATH = './error.compiled.mustache'

const viewTemplate = fs.readFileSync(path.join(__dirname, VIEW_PATH), 'utf-8')
Expand Down Expand Up @@ -131,17 +132,13 @@ class Youch {
*
* @return {String}
*/
_getDisplayClasses (frame, index) {
_getDisplayClasses (frame) {
const classes = []
if (index === 0) {
classes.push('active')
}

if (!frame.isApp) {
classes.push('native-frame')
}

return classes.join(' ')
return classes
}

/**
Expand Down Expand Up @@ -344,12 +341,22 @@ class Youch {
return new Promise((resolve, reject) => {
this._parseError()
.then((stack) => {
let foundActiveFrame = false

const data = this._serializeData(stack, (frame, index) => {
const serializedFrame = this._serializeFrame(frame)
serializedFrame.classes = this._getDisplayClasses(
serializedFrame,
index
)
const classes = this._getDisplayClasses(serializedFrame)

/**
* Adding active class to first app framework
*/
if (!foundActiveFrame && (serializedFrame.isApp || index + 1 === stack.length)) {
classes.push('active')
foundActiveFrame = true
}

serializedFrame.classes = classes.join(' ')

return serializedFrame
})

Expand Down

0 comments on commit 2fdcded

Please sign in to comment.