mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Don't transform deprecated selectors for bundled packages
This commit is contained in:
@@ -204,7 +204,17 @@ class Package
|
||||
else
|
||||
context = undefined
|
||||
|
||||
@stylesheetDisposables.add(@styleManager.addStyleSheet(source, {sourcePath, priority, context}))
|
||||
@stylesheetDisposables.add(
|
||||
@styleManager.addStyleSheet(
|
||||
source,
|
||||
{
|
||||
sourcePath,
|
||||
priority,
|
||||
context,
|
||||
skipDeprecatedSelectorsTransformation: @bundledPackage
|
||||
}
|
||||
)
|
||||
)
|
||||
@stylesheetsActivated = true
|
||||
|
||||
activateResources: ->
|
||||
|
||||
@@ -137,29 +137,17 @@ module.exports = class StyleManager {
|
||||
}
|
||||
}
|
||||
|
||||
let transformed
|
||||
if (this.cacheDirPath != null) {
|
||||
const hash = crypto.createHash('sha1')
|
||||
if (params.context != null) {
|
||||
hash.update(params.context)
|
||||
}
|
||||
hash.update(source)
|
||||
const cacheFilePath = path.join(this.cacheDirPath, hash.digest('hex'))
|
||||
try {
|
||||
transformed = JSON.parse(fs.readFileSync(cacheFilePath))
|
||||
} catch (e) {
|
||||
transformed = transformDeprecatedShadowDOMSelectors(source, params.context)
|
||||
fs.writeFileSync(cacheFilePath, JSON.stringify(transformed))
|
||||
}
|
||||
if (params.skipDeprecatedSelectorsTransformation) {
|
||||
styleElement.textContent = source
|
||||
} else {
|
||||
transformed = transformDeprecatedShadowDOMSelectors(source, params.context)
|
||||
const transformed = this.upgradeDeprecatedSelectorsForStyleSheet(source, params.context)
|
||||
styleElement.textContent = transformed.source
|
||||
if (transformed.deprecationMessage) {
|
||||
this.deprecationsBySourcePath[params.sourcePath] = {message: transformed.deprecationMessage}
|
||||
this.emitter.emit('did-update-deprecations')
|
||||
}
|
||||
}
|
||||
|
||||
styleElement.textContent = transformed.source
|
||||
if (transformed.deprecationMessage) {
|
||||
this.deprecationsBySourcePath[params.sourcePath] = {message: transformed.deprecationMessage}
|
||||
this.emitter.emit('did-update-deprecations')
|
||||
}
|
||||
if (updated) {
|
||||
this.emitter.emit('did-update-style-element', styleElement)
|
||||
} else {
|
||||
@@ -171,9 +159,10 @@ module.exports = class StyleManager {
|
||||
addStyleElement (styleElement) {
|
||||
let insertIndex = this.styleElements.length
|
||||
if (styleElement.priority != null) {
|
||||
for (let [index, existingElement] of this.styleElements.entries()) {
|
||||
for (let i = 0; i < this.styleElements.length; i++) {
|
||||
const existingElement = this.styleElements[i]
|
||||
if (existingElement.priority > styleElement.priority) {
|
||||
insertIndex = index
|
||||
insertIndex = i
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -197,6 +186,26 @@ module.exports = class StyleManager {
|
||||
}
|
||||
}
|
||||
|
||||
upgradeDeprecatedSelectorsForStyleSheet (styleSheet, context) {
|
||||
if (this.cacheDirPath != null) {
|
||||
const hash = crypto.createHash('sha1')
|
||||
if (context != null) {
|
||||
hash.update(context)
|
||||
}
|
||||
hash.update(styleSheet)
|
||||
const cacheFilePath = path.join(this.cacheDirPath, hash.digest('hex'))
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(cacheFilePath))
|
||||
} catch (e) {
|
||||
const transformed = transformDeprecatedShadowDOMSelectors(styleSheet, context)
|
||||
fs.writeFileSync(cacheFilePath, JSON.stringify(transformed))
|
||||
return transformed
|
||||
}
|
||||
} else {
|
||||
return transformDeprecatedShadowDOMSelectors(styleSheet, context)
|
||||
}
|
||||
}
|
||||
|
||||
getDeprecations () {
|
||||
return this.deprecationsBySourcePath
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user