-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Styles in separate files are ignored #121
Comments
CSSStyleDeclaration - Web APIs | MDN The documentation and online discussions make it sound like the following code should work, but it always returns an empty string:
Here's some of the code I tried: /** @type {CSSStyleDeclaration} */
const style = doc.defaultView.getComputedStyle(currentNode);
console.debug('---------------------------------------');
console.debug(`nodeName: ${currentNode.nodeName}`);
console.debug(`textContent: ${currentNode.textContent}`);
console.debug(`style: ${style}`);
console.debug(`style.getPropertyValue('display'): ${style.getPropertyValue('display')}`);
console.debug(`style.getPropertyValue('visibility'): ${style.getPropertyValue('visibility')}`); Output from copying the page's title:
/** @type {DocumentFragment} */
let frag = document.createDocumentFragment();
/** @type {Range} */
const startRange = getStartRange(selection);
frag.appendChild(startRange.cloneContents());
|
Readability.js also does not remove the hidden elements on ⦋2306.03872⦌ Deductive Verification of Chain-of-Thought Reasoning. (The function Here's the method Readability.js uses for finding hidden elements: _isProbablyVisible(node) {
// Have to null-check node.style and node.className.includes to deal with SVG and MathML nodes.
return (
(!node.style || node.style.display != "none") &&
(!node.style || node.style.visibility != "hidden") &&
!node.hasAttribute("hidden") &&
//check for "fallback-image" so that wikimedia math images are displayed
(!node.hasAttribute("aria-hidden") ||
node.getAttribute("aria-hidden") != "true" ||
(node.className &&
node.className.includes &&
node.className.includes("fallback-image")))
);
}, |
When Stardown copies part of a page, it sometimes needs to look at the page's style for certain things such as whether an element is hidden (
display: none
,visibility: hidden
, etc.) in Stardown'sremoveHiddenElements
function. However, it appears to be unable to see styles defined in CSS files separate from the HTML.To Reproduce
Steps to reproduce the behavior:
Expected behavior
Title:
should not be in the output.Environment
Additional context
The element containing
Title:
has styledisplay: none
defined in CSS files separate from the HTML. Stardown now usesgetComputedStyle
in itsremoveHiddenElements
function to get element styles, but still fails to find thedisplay: none
.Stardown's
getSelectionFragment
function converts a Selection object into a DocumentFragment object. Printing this object to the console and inspecting it revealsdisplay: ""
. I'm not 100% sure if this means the DocumentFragment does not have access to styles that are not inline. I tried changing Stardown's selection-modifying code to include in each selection all of the selection's ancestor elements that include styles, but it had no effect so I removed the code without committing it.Since the
removeHiddenElements
function callsgetComputedStyle
with the livedocument
object, it seems like it should work even if the process of getting a Selection object and converting it to a DocumentFragment object somehow separates the HTML from the CSS, but it appears to not work.The text was updated successfully, but these errors were encountered: