Skip to content

Commit

Permalink
Merge branch 'release-3.0' into async-if-each
Browse files Browse the repository at this point in the history
  • Loading branch information
StorytellerCZ authored Sep 20, 2023
2 parents 76d0114 + 5210fb5 commit 6ef78a3
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 164 deletions.
9 changes: 9 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## v3.0.0, 2023-XXXX-XX

### Potentially breaking changes
* [#373](https://github.com/meteor/blaze/pull/373) Remove fibers from codebase
* [#378](https://github.com/meteor/blaze/pull/378) [spacebars-compiler] Update uglify-js to 3.16.1
* [#351](https://github.com/meteor/blaze/pull/351) Eliminate whitespace in Template.dynamic
* [#334](https://github.com/meteor/blaze/pull/334) Faster fragnent parsing by retaining a reference to the current document context

## v2.7.1, 2023-May-26

* [#413](https://github.com/meteor/blaze/pull/418) Fix reactivity for non-primitives.
Expand All @@ -14,6 +22,7 @@
* [#405](https://github.com/meteor/blaze/pull/406) Stop establishing unnecessary reactive dependencies
* [#410](https://github.com/meteor/blaze/pull/410) Fixes for legacy clients


## v2.6.1, 2022-July-25

* [#370](https://github.com/meteor/blaze/pull/370) `templating-runtime@1.6.1`, returned the `Template.__define__` with warning message
Expand Down
21 changes: 20 additions & 1 deletion packages/blaze/dombackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,32 @@ if (! $jq)

DOMBackend._$jq = $jq;


DOMBackend.getContext = function() {
if (DOMBackend._context) {
return DOMBackend._context;
}
if ( DOMBackend._$jq.support.createHTMLDocument ) {
DOMBackend._context = document.implementation.createHTMLDocument( "" );

// Set the base href for the created document
// so any parsed elements with URLs
// are based on the document's URL (gh-2965)
const base = DOMBackend._context.createElement( "base" );
base.href = document.location.href;
DOMBackend._context.head.appendChild( base );
} else {
DOMBackend._context = document;
}
return DOMBackend._context;
}
DOMBackend.parseHTML = function (html) {
// Return an array of nodes.
//
// jQuery does fancy stuff like creating an appropriate
// container element and setting innerHTML on it, as well
// as working around various IE quirks.
return $jq.parseHTML(html) || [];
return $jq.parseHTML(html, DOMBackend.getContext()) || [];
};

DOMBackend.Events = {
Expand Down
62 changes: 32 additions & 30 deletions packages/caching-html-compiler/caching-html-compiler.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/* global TemplatingTools CachingCompiler */
// eslint-disable-next-line import/no-unresolved
import isEmpty from 'lodash.isempty';

const path = Plugin.path;
const { path } = Plugin;

// The CompileResult type for this CachingCompiler is the return value of
// htmlScanner.scan: a {js, head, body, bodyAttrs} object.
// eslint-disable-next-line no-undef
CachingHtmlCompiler = class CachingHtmlCompiler extends CachingCompiler {
/**
* Constructor for CachingHtmlCompiler
Expand All @@ -18,7 +21,7 @@ CachingHtmlCompiler = class CachingHtmlCompiler extends CachingCompiler {
constructor(name, tagScannerFunc, tagHandlerFunc) {
super({
compilerName: name,
defaultCacheSize: 1024*1024*10,
defaultCacheSize: 1024 * 1024 * 10,
});

this._bodyAttrInfo = null;
Expand All @@ -28,12 +31,13 @@ CachingHtmlCompiler = class CachingHtmlCompiler extends CachingCompiler {
}

// Implements method from CachingCompilerBase
// eslint-disable-next-line class-methods-use-this
compileResultSize(compileResult) {
function lengthOrZero(field) {
return field ? field.length : 0;
}
return lengthOrZero(compileResult.head) + lengthOrZero(compileResult.body) +
lengthOrZero(compileResult.js);
const lengthOrZero = (field) => field ? field.length : 0;
const headSize = lengthOrZero(compileResult.head);
const bodySize = lengthOrZero(compileResult.body);
const jsSize = lengthOrZero(compileResult.js);
return headSize + bodySize + jsSize;
}

// Overrides method from CachingCompiler
Expand All @@ -43,13 +47,14 @@ CachingHtmlCompiler = class CachingHtmlCompiler extends CachingCompiler {
}

// Implements method from CachingCompilerBase
// eslint-disable-next-line class-methods-use-this
getCacheKey(inputFile) {
// Note: the path is only used for errors, so it doesn't have to be part
// of the cache key.
return [
inputFile.getArch(),
inputFile.getSourceHash(),
inputFile.hmrAvailable && inputFile.hmrAvailable()
inputFile.hmrAvailable && inputFile.hmrAvailable(),
];
}

Expand All @@ -60,34 +65,33 @@ CachingHtmlCompiler = class CachingHtmlCompiler extends CachingCompiler {
try {
const tags = this.tagScannerFunc({
sourceName: inputPath,
contents: contents,
tagNames: ["body", "head", "template"]
contents,
tagNames: ['body', 'head', 'template'],
});

return this.tagHandlerFunc(tags, inputFile.hmrAvailable && inputFile.hmrAvailable());
} catch (e) {
if (e instanceof TemplatingTools.CompileError) {
inputFile.error({
message: e.message,
line: e.line
line: e.line,
});
return null;
} else {
throw e;
}
throw e;
}
}

// Implements method from CachingCompilerBase
addCompileResult(inputFile, compileResult) {
let allJavaScript = "";
let allJavaScript = '';

if (compileResult.head) {
inputFile.addHtml({ section: "head", data: compileResult.head });
inputFile.addHtml({ section: 'head', data: compileResult.head });
}

if (compileResult.body) {
inputFile.addHtml({ section: "body", data: compileResult.body });
inputFile.addHtml({ section: 'body', data: compileResult.body });
}

if (compileResult.js) {
Expand All @@ -97,19 +101,19 @@ CachingHtmlCompiler = class CachingHtmlCompiler extends CachingCompiler {
if (!isEmpty(compileResult.bodyAttrs)) {
Object.keys(compileResult.bodyAttrs).forEach((attr) => {
const value = compileResult.bodyAttrs[attr];
if (this._bodyAttrInfo.hasOwnProperty(attr) &&
if (Object.prototype.hasOwnProperty.call(this._bodyAttrInfo, attr) &&
this._bodyAttrInfo[attr].value !== value) {
// two conflicting attributes on <body> tags in two different template
// files
inputFile.error({
message:
`<body> declarations have conflicting values for the '${ attr }' ` +
`attribute in the following files: ` +
this._bodyAttrInfo[attr].inputFile.getPathInPackage() +
`, ${ inputFile.getPathInPackage() }`
`${`<body> declarations have conflicting values for the '${attr}' ` +
'attribute in the following files: '}${
this._bodyAttrInfo[attr].inputFile.getPathInPackage()
}, ${inputFile.getPathInPackage()}`,
});
} else {
this._bodyAttrInfo[attr] = {inputFile, value};
this._bodyAttrInfo[attr] = { inputFile, value };
}
});

Expand All @@ -123,25 +127,23 @@ CachingHtmlCompiler = class CachingHtmlCompiler extends CachingCompiler {
});
`;
}


if (allJavaScript) {
const filePath = inputFile.getPathInPackage();
// XXX this path manipulation may be unnecessarily complex
let pathPart = path.dirname(filePath);
if (pathPart === '.')
pathPart = '';
if (pathPart.length && pathPart !== path.sep)
pathPart = pathPart + path.sep;
if (pathPart === '.') pathPart = '';
if (pathPart.length && pathPart !== path.sep) pathPart += path.sep;
const ext = path.extname(filePath);
const basename = path.basename(filePath, ext);

// XXX generate a source map

inputFile.addJavaScript({
path: path.join(pathPart, "template." + basename + ".js"),
data: allJavaScript
path: path.join(pathPart, `template.${basename}.js`),
data: allJavaScript,
});
}
}
}
};
17 changes: 7 additions & 10 deletions packages/caching-html-compiler/package.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
/* eslint-env meteor */
Package.describe({
name: 'caching-html-compiler',
summary: "Pluggable class for compiling HTML into templates",
summary: 'Pluggable class for compiling HTML into templates',
version: '1.2.1',
git: 'https://github.com/meteor/blaze.git'
git: 'https://github.com/meteor/blaze.git',
});

Npm.depends({
'lodash.isempty': '4.4.0'
'lodash.isempty': '4.4.0',
});

Package.onUse(function(api) {
api.use([
'caching-compiler@1.2.2',
'ecmascript@0.15.1'
'ecmascript@0.15.1',
]);

api.export('CachingHtmlCompiler', 'server');

api.use([
'templating-tools@1.2.1'
]);
api.use(['templating-tools@1.2.1']);

api.addFiles([
'caching-html-compiler.js'
], 'server');
api.addFiles(['caching-html-compiler.js'], 'server');
});
91 changes: 3 additions & 88 deletions packages/spacebars-compiler/.npm/package/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/spacebars-compiler/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export function beautify (code) {
}

var result = UglifyJSMinify(code, {
fromString: true,
mangle: false,
compress: false,
output: {
Expand Down
2 changes: 1 addition & 1 deletion packages/spacebars-compiler/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Package.describe({
});

Npm.depends({
'uglify-js': '2.7.5'
'uglify-js': '3.16.1'
});

Package.onUse(function (api) {
Expand Down
Loading

0 comments on commit 6ef78a3

Please sign in to comment.