I have noticed that in dojo source code there are two ways people are creating their nls files. It's about the use of parentheses.
https://github.com/dojo/dojo/blob/master/nls/colors.js:
define({
root: ({
aliceblue: "alice blue",
antiquewhite: "antique white",
(..)
})
})
https://github.com/dojo/dojo/blob/master/tests/nls/salutations.js:
define({
root: {
ar: "Arabic",
cs: "Czech",
(..)
}
})
Both are parsed correctly and it seems that dojo doesn't care if and how many additional parentheses there is (as long as the number of closing parentheses matches the number of opening parentheses).
The same way additional parentheses can be added to the define block.
Is there anything gained by enclosing the root value in parentheses?
Related
I am setting alias values and then comparing them but I'm running into an issue because the element is listed twice within the same top level class. This is causing the alias value to be "latest latest", Cypress is adding a space automatically. I thought I would be able to just say .first() and then alias it but it still adds a space.
Here's my code:
cy.get('[data-automation="data-row-value-currentVersion"]')
.first() // using first() b/c UpdatedBy nested block repeats the current version value
.invoke('text').then(currentVersion => {
cy.wrap(currentVersion).as('currentVersion');
});
cy.get('[data-automation="active-version"]')
.invoke('text').then(activeVersion => {
cy.wrap(activeVersion).as('activeVersion');
});
cy.get('#activeVersion').then(activeVersion => {
cy.get('#currentVersion').then(currentVersion => {
cy.log(`-${activeVersion}-`);
cy.log(`--${currentVersion}--`);
expect(activeVersion).to.eq(currentVersion);
});
});
});
The assert fails because of the space that Cypress automatically adds.The cy.logs were just for me to actually see what value was being aliased.
Any ideas?
There's always an overlap with Navbar dropdown when more than one is clicked. It focuses and takes a few minutes to clear this becomes a problem because it causes clutter.
The configuration for this in the Vuepress docs is just to add navbar items and ariaLabel any know how I can stop this behaviour.
themeConfig: {
nav: [
{
text: 'Languages',
ariaLabel: 'Language Menu',
items: [
{ text: 'Chinese', link: '/language/chinese/' },
{ text: 'Japanese', link: '/language/japanese/' }
]
}
]
}
Here's an example
To answer your question one would need to address two distinct issues:
how do I run custom JavaSCript in VuePress?
how do I close any previously open dropdowns on click in my current VuePress theme, using JavaScript?
For the first problem there are several solutions (one of them being by using a custom component with code run in its mounted() hook, but this would require you to include that component in every page and make sure it doesn't run more than one time (since you want to bind events to elements).
I believe the cleanest way would be by adding a <script> to <head> which can be achieved by adding this to the head prop of your .vuepress/config.js export:
head: [
// ...existing stuff, if any,
['script', {}, `
(function() {
// your code here...
})();
`]
]
However, there are a few problems with the above solution. Firstly, it's going to be run as soon as it's parsed, and that's inside the <head> tag. Which means none of the contents of your page are rendered yet. And the second problem is you're in a template literal. You don't really want to be writing JavaScript code in a template literal. Ideally you should be able to put your code in a '.js' file and append it as a <script> tag.
In order to do that, you need to create a .vuepress/public/ folder, if you don't already have one. Place your .js file in there (I used test.js but feel free to name it as you like). Modify the above code to:
['script', {}, `
(function() {
var s = document.createElement('script');
s.src = './test.js';
var h = document.querySelector('head');
h.appendChild(s);
})();
`]
Change ./test.js to your file's name.
Now your file has clean JavaScript and the door is open. Your code executes in the window object context.
To answer the second part of your question, well..., it largely depends on the theme you are using. If you're using the default theme (which seems to be the case, from the SS you posted), this should work, if placed inside your .js file:
document.addEventListener('DOMContentLoaded', fixDropDowns);
function fixDropDowns() {
document.body.addEventListener('click', (ev) => {
const header = document.querySelector('header');
if (header) {
const dds = header.querySelectorAll('.dropdown-wrapper');
[...dds].forEach(el => el.classList.remove('open'));
const curr = ev.target.closest('.dropdown-wrapper');
if (curr) {
curr.classList.add('open');
}
}
})
}
But it's based on a close inspection of the generated markup.
Specifically on the fact the dropdowns have a class of .dropdown-wrapper and that they're opened by toggling class open on them. The above is just an example and will likely not work on other themes and might even stop working on the default theme in some future version.
In Sublime 2, I know how to reindent the whole document and how to assign a key to this function, but I want to reindent as is do in WebStorm where spaces are added before and after a (=) or after and before a (:). Watch the image for the examples. How could I do that in Sublime or what package do this?
Use:
HTML-CSS-JS Prettify
You can adjust the following settings #:
Menu > Preferences > Package Settings > HTML/CSS/JS Prettify > Set Prettify Preferences
"js": {
"allowed_file_extensions": ["js", "json", "jshintrc", "jsbeautifyrc"],
"brace_style": "collapse-preserve-inline",
// collapse: (old default) Put braces on the same line as control statements
// collapse-preserve-inline: (new default) Same as collapse but better support for ES6 destructuring and other features. https: //github.com/victorporof/Sublime-HTMLPrettify/issues/231
// expand: Put braces on own line (Allman / ANSI style)
// end-expand: Put end braces on own line
// none: Keep them where they are
"break_chained_methods": false, // Break chained method calls across subsequent lines
"e4x": false, // Pass E4X xml literals through untouched
"end_with_newline": false, // End output with newline
"indent_char": " ", // Indentation character
"indent_level": 0, // Initial indentation level
"indent_size": 2, // Indentation size
"indent_with_tabs": true, // Indent with tabs, overrides `indent_size` and `indent_char`
"jslint_happy": false, // If true, then jslint-stricter mode is enforced
"keep_array_indentation": false, // Preserve array indentation
"keep_function_indentation": false, // Preserve function indentation
"max_preserve_newlines": 0, // Maximum number of line breaks to be preserved in one chunk (0 disables)
"preserve_newlines": true, // Whether existing line breaks should be preserved
"space_after_anon_function": false, // Should the space before an anonymous function's parens be added, "function()" vs "function ()"
"space_before_conditional": true, // Should the space before conditional statement be added, "if(true)" vs "if (true)"
"space_in_empty_paren": false, // Add padding spaces within empty paren, "f()" vs "f( )"
"space_in_paren": false, // Add padding spaces within paren, ie. f( a, b )
"unescape_strings": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65"
"wrap_line_length": 0 // Lines should wrap at next opportunity after this number of characters (0 disables)
}
Note:
It does not handle commas within quotes.
I also tested CoolFormat, which does not handle them either.
You should check out Will Bond's Alignment plugin, it should do most of what you want, and is pretty configurable as well. There seems to be an issue with the documentation and circular links between packagecontrol.io and wbond.net, but here is the documentation stored in the Wayback Machine.
I want to have a gulp task in Visual Studio Code which watches all files in a folder called less with the extension .less. When found, a task must compile the less files to a folder called css on the same level as the less folder.
Current code:
gulp.task('less', function() {
gulp.src('less/*.less',{ cwd:'..' })
.pipe(less())
.pipe(gulp.dest( 'css' ), { cwd:'..' });
});
gulp.task('default', function() {
gulp.watch('./**/less/*.less', ['less']);
});
What I want:
x
y
less
style.less
css
style.css
What above code does:
x
y
less
style.less
css
y
less
style.css
I had this working when being specific in the path, but the problem is that i've less folders on multiple levels. How can I solve this?
I know this is bit old question, but felt worth sharing my answer.
gulp.task('app:less', [], function () {
return gulp.src(['./src/**/*.less'], { base: './src/' })
.pipe(less())
.pipe(gulp.dest('./src/'));
});
Setting base option to root folder with dest path to ./src/ worked for me.
Currently there is no way to do it. The only thing which could approach you to a solution is gulp-flatten. However, this requires to specify a fixed number of parents to include. In your case, where you have folders in different levels, you'd need to specify a different number for each case. So, the only option would be to modify the flatten code to support something like an excludeParents, which does the contrary that flatten, i.e exclude a fixed number of parents (in your case, 1).
Try this :
gulp.task('less', function() {
gulp.src(['**/*.less', *.less],{ cwd:'less' })
.pipe(less())
.pipe(gulp.dest('css'));
});
This seems trivial, but I'm attempting to set up a functional test in Intern to check the inner text of a set of span elements in my page all with the same CSS class, but I can't seem to be able to isolate the text within the span. Here is my code:
'Span check': function () {
return this.remote
.findAllByClassName('mySpanClass')
.then(function (elems) {
assert.strictEqual(elems[0].innerHTML(),'Span Text');
})
}
I've run separate tests to verify that the spans are being found... the findAllByClassName function returns an array of two Objects.
Anyone done anything like this?
You need to use getVisibleText() instead:
Gets the visible text within the element. elements are converted
to line breaks in the returned text, and whitespace is normalised per
the usual XML/HTML whitespace normalisation rules.
return this.remote
.findByCssSelector('.mySpanClass')
.getVisibleText()
.then(function (text) {
assert.strictEqual(text, 'Span Text');
});
This would work for a single element.
If you want to check the text of each span, use:
return this.remote
.findAllByCssSelector('.mySpanClass')
.getVisibleText()
.then(function (texts) {
assert.strictEqual(texts, ['Span1 Text', 'Span2 Text']);
});