How to use the @dojo/framework/core/has function in @dojo/framework

To help you get started, we’ve selected a few @dojo/framework examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dojo / cli-build-app / test-app / src / main.ts View on Github external
import App from './App';
import * as css from './app.m.css';
import './Bar';
import LazyApp from './LazyApp';
import routes from './routes';
import test from './test.block';

'!has("bar")';

if (has('foo')) {
	console.log('foo');
}

const root = document.getElementById('app');

const btr = has('build-time-render');

App().then((result) => {
	console.log(result());
	console.log(require('foo/bar'));
});
let div = document.getElementById('div');
if (!div) {
	div = document.createElement('div');
	div.id = 'div';
}
if (btr) {
	test('./src/foo.txt').then((result: string) => {
		const nodeBtr = document.createElement('div');
		nodeBtr.id = 'nodeBtr';
		nodeBtr.innerHTML = result;
		root!.appendChild(nodeBtr);
github dojo / cli-build-app / test-app / src / main.ts View on Github external
}

if (has('dojo-debug')) {
	div.setAttribute('dojo-debug', 'true');
}

if (has('env') === 'prod') {
	div.setAttribute('has-prod', 'prod');
}

if (has('env') === 'ci') {
	div.setAttribute('has-ci', 'ci');
}

div.textContent = `Built with Build Time Render: ${!!div.getAttribute('hasBtr')}
Currently Rendered by BTR: ${has('build-time-render')}`;

div.classList.add(...css.root.split(' '));
if (div.parentNode === null) {
	root!.appendChild(div);
}

const appRoot = document.getElementById('app-root')!;
console.log(appRoot);

const registry = new Registry();
const router = registerRouterInjector(routes, registry);

if (!btr) {
	router.setPath('/foo/bar');
}
github dojo / cli-build-app / test-app / src / main.ts View on Github external
import has from '@dojo/framework/core/has';
import renderer, { w } from '@dojo/framework/core/vdom';
import Registry from '@dojo/framework/core/Registry';
import { registerRouterInjector } from '@dojo/framework/routing/RouterInjector';
import App from './App';
import * as css from './app.m.css';
import './Bar';
import LazyApp from './LazyApp';
import routes from './routes';
import test from './test.block';

'!has("bar")';

if (has('foo')) {
	console.log('foo');
}

const root = document.getElementById('app');

const btr = has('build-time-render');

App().then((result) => {
	console.log(result());
	console.log(require('foo/bar'));
});
let div = document.getElementById('div');
if (!div) {
	div = document.createElement('div');
	div.id = 'div';
}
github dojo / cli-build-app / test-app / src / main.ts View on Github external
});
	div.setAttribute('hasBtr', 'true');
} else {
	const nodeBtrCache = document.createElement('div');
	nodeBtrCache.id = 'nodeBtrCache';
	test('./src/foo.txt').then((result: string) => {
		nodeBtrCache.innerHTML = result;
	});
	root!.appendChild(nodeBtrCache);
}

if (process.env.NODE_ENV === 'production') {
	div.setAttribute('nodeenv', 'production');
}

if (has('dojo-debug')) {
	div.setAttribute('dojo-debug', 'true');
}

if (has('env') === 'prod') {
	div.setAttribute('has-prod', 'prod');
}

if (has('env') === 'ci') {
	div.setAttribute('has-ci', 'ci');
}

div.textContent = `Built with Build Time Render: ${!!div.getAttribute('hasBtr')}
Currently Rendered by BTR: ${has('build-time-render')}`;

div.classList.add(...css.root.split(' '));
if (div.parentNode === null) {
github gothinkster / dojo-realworld-example-app / src / store.ts View on Github external
const store = createStoreMiddleware((store: Store) => {
	let session: any;
	if (!has('build-time-render') && global.sessionStorage) {
		session = global.sessionStorage.getItem('conduit-session');
	}
	if (session) {
		setSessionProcess(store)({ session: JSON.parse(session) });
	}
	getTagsProcess(store)({});
	router.on('nav', ({ outlet, context }: any) => {
		changeRouteProcess(store)({ outlet, context });
	});

	function onRouteChange() {
		const outlet = store.get(store.path('routing', 'outlet'));
		const params = store.get(store.path('routing', 'params'));
		if (outlet) {
			const link = router.link(outlet, params);
			if (link !== undefined) {
github dojo / examples / realworld / src / store.ts View on Github external
const store = createStoreMiddleware((store: Store) => {
	let session: any;
	if (!has("build-time-render") && !has("test")) {
		session = global.sessionStorage.getItem("conduit-session");
	}
	if (session) {
		setSessionProcess(store)({ session: JSON.parse(session) });
	}
	getTagsProcess(store)({});
	router.on("nav", ({ outlet, context }: any) => {
		changeRouteProcess(store)({ outlet, context });
	});

	function onRouteChange() {
		const outlet = store.get(store.path("routing", "outlet"));
		const params = store.get(store.path("routing", "params"));
		if (outlet) {
			const link = router.link(outlet, params);
			if (link !== undefined) {
github dojo / examples / hnpwa / src / widgets / Comments.tsx View on Github external
export default factory(function Comments({ properties, middleware: { icache } }) {
	const { id } = properties();
	let item: ArticleItem | undefined;
	if (!has('build-time-render')) {
		item = icache.getOrSet('comment', async () => {
			const response = await fetch(`https://node-hnapi.herokuapp.com/item/${id}`);
			const item = await response.json();
			return item;
		});
	}

	if (!item) {
		return ;
	}

	return (
		
			<article>
				<h1>
					<a href="{item.url}"></a></h1></article>
github dojo / examples / hnpwa / src / widgets / Content.tsx View on Github external
export default factory(function Content({ properties, middleware: { icache } }) {
	const { page, category } = properties();
	let articles = [];
	if (!has('build-time-render')) {
		articles =
			icache.getOrSet('articles', async () =&gt; {
				const catKey = category === 'top' ? 'news' : category === 'new' ? 'newest' : category;
				const response = await fetch(`https://node-hnapi.herokuapp.com/${catKey}?page=${page}`);
				const articles = await response.json();
				return articles;
			}) || [];
	}
	const articlesNodes = [];
	const length = articles.length || 30;
	for (let index = 0; index &lt; length; index++) {
		articlesNodes.push(<article>);
	}
	return (
		<div>
			<div></div></div></article>
github dojo / widgets / src / examples / src / Example.tsx View on Github external
<div>{children()}</div>
		
	];
	if (content) {
		tabs.push(
			
				<div>
					<pre>						<code>
					</code></pre><code>
				</code></div><code>
			</code><code>
		);
	}
	if (!has('docs')) {
		tabs.push(
			
				<div>
					{activeTab === tabNames.indexOf('tests') &amp;&amp; (
						</div></code>