Socket
Socket
Sign inDemoInstall

ng-meta

Package Overview
Dependencies
1
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.0.3

4

bower.json
{
"name": "ngMeta",
"version": "1.0.2",
"version": "1.0.3",
"authors": [

@@ -36,2 +36,2 @@ "Vinay Gopinath <vinayg18@gmail.com>"

}
}
}
#Changelog
## [v1.0.3](https://github.com/vinaygopinath/ngMeta/releases/tag/v1.0.3)
#### Features
* [#41](https://github.com/vinaygopinath/ngMeta/pull/41) Added `resetMeta` to apply default tags in the resolve function of ui-router when `disableUpdate` is `true`. Thanks [jacobcsmith](https://github.com/jacobcsmith)
## [v1.0.2](https://github.com/vinaygopinath/ngMeta/releases/tag/v1.0.2)

@@ -4,0 +10,0 @@

@@ -137,3 +137,3 @@ (function(root, factory) {

*
* @returns {Object} self
* @returns void
*/

@@ -174,3 +174,17 @@ var readRouteMeta = function(meta) {

/**
* @ngdoc method
* @name resetMeta
* @description
* Helper function to reset ngMeta data and apply defaults. Useful when setting up ngmeta data in a
* UI-router resolve function.
*
* @returns {Object} self
*/
var resetMeta = function() {
readRouteMeta();
return this;
};
/**

@@ -208,3 +222,4 @@ * @ngdoc method

'setTag': setTag,
'setDefaultTag': setDefaultTag
'setDefaultTag': setDefaultTag,
'resetMeta' : resetMeta
};

@@ -211,0 +226,0 @@ }

@@ -1,4 +0,4 @@

/* ngMeta - v1.0.2 - 24-Aug-2017
/* ngMeta - v1.0.3 - 14-May-2018
https://github.com/vinaygopinath/ngMeta
*/
!function(a,b){"function"==typeof define&&define.amd?define(["angular"],b):"object"==typeof exports?module.exports=b(require("angular")):a.returnExports=b(a.angular)}(this,function(a){return a.module("ngMeta",[]).provider("ngMeta",function(){"use strict";function b(b,e){var f=function(e,f){if(!b.ngMeta)throw new Error("Cannot call setTitle when ngMeta is undefined. Did you forget to call ngMeta.init() in the run block? \nRefer: https://github.com/vinaygopinath/ngMeta#getting-started");return b.ngMeta.title=a.isDefined(e)?e:c.title||"",d.useTitleSuffix&&(b.ngMeta.title+=a.isDefined(f)?f:c.titleSuffix||""),this},g=function(d,e){if(!b.ngMeta)throw new Error("Cannot call setTag when ngMeta is undefined. Did you forget to call ngMeta.init() in the run block? \nRefer: https://github.com/vinaygopinath/ngMeta#getting-started");if("title"===d||"titleSuffix"===d)throw new Error("Attempt to set '"+d+"' through 'setTag': 'title' and 'titleSuffix' are reserved tag names. Please use 'ngMeta.setTitle' instead");return b.ngMeta[d]=a.isDefined(e)?e:c[d],this},h=function(a,d){if(!b.ngMeta)throw new Error("Cannot call setDefaultTag when ngMeta is undefined. Did you forget to call ngMeta.init() in the run block? \nRefer: https://github.com/vinaygopinath/ngMeta#getting-started");return c[a]=d,"title"===a||"titleSuffix"===a?this.setTitle(b.ngMeta.title,b.ngMeta.titleSuffix):this.setTag(a,b.ngMeta[a]),this},i=function(b){if(b=b||{},b.disableUpdate)return!1;f(b.title,b.titleSuffix);var d=a.copy(c);delete b.title,delete b.titleSuffix,delete d.title,delete d.titleSuffix;for(var e=Object.keys(b),h=0;h<e.length;h++)d.hasOwnProperty(e[h])&&delete d[e[h]],g(e[h],b[e[h]]);for(var i=Object.keys(d),j=0;j<i.length;j++)g(i[j],d[i[j]])},j=function(b,c){i(a.copy(c.meta||c.data&&c.data.meta))};return{init:function(){if(b.ngMeta={},b.$on("$routeChangeSuccess",j),b.$on("$stateChangeSuccess",j),e.has("$transitions")){e.get("$transitions").onSuccess({},function(a){j(null,a.$to())})}},setTitle:f,setTag:g,setDefaultTag:h}}var c={},d={useTitleSuffix:!1};this.setDefaultTitle=function(a){return c.title=a,this},this.setDefaultTitleSuffix=function(a){return c.titleSuffix=a,this},this.setDefaultTag=function(a,b){return c[a]=b,this},this.useTitleSuffix=function(a){return d.useTitleSuffix=!!a,this},this.mergeNestedStateData=function(b,c){var d=c(b)||{},e=b.parent&&b.parent.data&&b.parent.data.meta;if(d.meta||e){var f=a.merge({},e,d.meta);d.meta=f}return b.self.data=d,d},this.$get=["$rootScope","$injector",function(a,c){return new b(a,c)}]})});
!function(a,b){"function"==typeof define&&define.amd?define(["angular"],b):"object"==typeof exports?module.exports=b(require("angular")):a.returnExports=b(a.angular)}(this,function(a){return a.module("ngMeta",[]).provider("ngMeta",function(){"use strict";function b(b,e){var f=function(e,f){if(!b.ngMeta)throw new Error("Cannot call setTitle when ngMeta is undefined. Did you forget to call ngMeta.init() in the run block? \nRefer: https://github.com/vinaygopinath/ngMeta#getting-started");return b.ngMeta.title=a.isDefined(e)?e:c.title||"",d.useTitleSuffix&&(b.ngMeta.title+=a.isDefined(f)?f:c.titleSuffix||""),this},g=function(d,e){if(!b.ngMeta)throw new Error("Cannot call setTag when ngMeta is undefined. Did you forget to call ngMeta.init() in the run block? \nRefer: https://github.com/vinaygopinath/ngMeta#getting-started");if("title"===d||"titleSuffix"===d)throw new Error("Attempt to set '"+d+"' through 'setTag': 'title' and 'titleSuffix' are reserved tag names. Please use 'ngMeta.setTitle' instead");return b.ngMeta[d]=a.isDefined(e)?e:c[d],this},h=function(a,d){if(!b.ngMeta)throw new Error("Cannot call setDefaultTag when ngMeta is undefined. Did you forget to call ngMeta.init() in the run block? \nRefer: https://github.com/vinaygopinath/ngMeta#getting-started");return c[a]=d,"title"===a||"titleSuffix"===a?this.setTitle(b.ngMeta.title,b.ngMeta.titleSuffix):this.setTag(a,b.ngMeta[a]),this},i=function(b){if(b=b||{},b.disableUpdate)return!1;f(b.title,b.titleSuffix);var d=a.copy(c);delete b.title,delete b.titleSuffix,delete d.title,delete d.titleSuffix;for(var e=Object.keys(b),h=0;h<e.length;h++)d.hasOwnProperty(e[h])&&delete d[e[h]],g(e[h],b[e[h]]);for(var i=Object.keys(d),j=0;j<i.length;j++)g(i[j],d[i[j]])},j=function(b,c){i(a.copy(c.meta||c.data&&c.data.meta))},k=function(){return i(),this};return{init:function(){if(b.ngMeta={},b.$on("$routeChangeSuccess",j),b.$on("$stateChangeSuccess",j),e.has("$transitions")){e.get("$transitions").onSuccess({},function(a){j(null,a.$to())})}},setTitle:f,setTag:g,setDefaultTag:h,resetMeta:k}}var c={},d={useTitleSuffix:!1};this.setDefaultTitle=function(a){return c.title=a,this},this.setDefaultTitleSuffix=function(a){return c.titleSuffix=a,this},this.setDefaultTag=function(a,b){return c[a]=b,this},this.useTitleSuffix=function(a){return d.useTitleSuffix=!!a,this},this.mergeNestedStateData=function(b,c){var d=c(b)||{},e=b.parent&&b.parent.data&&b.parent.data.meta;if(d.meta||e){var f=a.merge({},e,d.meta);d.meta=f}return b.self.data=d,d},this.$get=["$rootScope","$injector",function(a,c){return new b(a,c)}]})});
{
"name": "ng-meta",
"version": "1.0.2",
"version": "1.0.3",
"description": "Meta tags support for AngularJS single page applications (SPA)",
"main": "dist/ngMeta.js",
"directories": {
"example": "examples",
"test": "test"
},
"scripts": {
"test": "grunt test"
"test": "grunt test",
"build": "grunt dist"
},

@@ -50,2 +47,2 @@ "repository": {

}
}
}

@@ -37,3 +37,3 @@ # ngMeta

```shell
https://cdnjs.cloudflare.com/ajax/libs/ng-meta/0.3.9/ngMeta.min.js
https://cdnjs.cloudflare.com/ajax/libs/ng-meta/1.0.3/ngMeta.min.js
```

@@ -53,3 +53,3 @@

.config(function ($routeProvider, ngMetaProvider) {
$routeProvider

@@ -84,3 +84,3 @@ .when('/home', {

// On /home, the title would change to
// On /home, the title would change to
// 'Home Page | Best Website on the Internet!'

@@ -100,3 +100,3 @@ ngMetaProvider.setDefaultTitleSuffix(' | Best Website on the Internet!');

})
.run(['ngMeta', function(ngMeta) {
.run(['ngMeta', function(ngMeta) {
ngMeta.init();

@@ -108,3 +108,3 @@ }]);

```html
<title ng-bind="ngMeta.title"></title>
<title ng-bind="ngMeta.title"></title>

@@ -162,2 +162,4 @@ <!-- Arbitrary tags -->

ngMeta.setDefaultTag('author', 'Default author');
//Set default tags (non-default tags, like author and image above, are NOT cleared)
ngMeta.resetMeta();
});

@@ -173,2 +175,3 @@ ```

| **setDefaultTag(String tagName, String value)** | Sets the default value of an arbitrary tag, overwriting previously set default values, but not the value set dynamically (using `setTitle`/`setTag`) or by the route/state. `title` and `titleSuffix` are accepted values.|ngMeta.setDefaultTag('image', 'http://default-image-url.com');<br/><br/>ngMeta.setDefaultTag('title','Default title');|
| **resetMeta(void)** | Applies the default meta tags. This is relevant when using ui-router and `disableUpdate: true` (Refer [this comment](https://github.com/vinaygopinath/ngMeta/pull/41#issuecomment-387143832)). Custom tags set dynamically (using `setTag` or `setTitle`) are **not** cleared. |ngMeta.resetMeta();|

@@ -180,3 +183,3 @@

* Facebook's [Open Graph Object Debugger](https://developers.facebook.com/tools/debug/og/object/) shows detailed information about your site's meta tags as well as a preview of the snippet shown when your site is shared.
* Facebook's [Open Graph Object Debugger](https://developers.facebook.com/tools/debug/og/object/) shows detailed information about your site's meta tags as well as a preview of the snippet shown when your site is shared. **Note that you need to use server-side rendering or prerendering in combination with ngMeta to see your meta tags in the the debugger**

@@ -183,0 +186,0 @@ ## Advanced

@@ -137,3 +137,3 @@ (function(root, factory) {

*
* @returns {Object} self
* @returns void
*/

@@ -174,3 +174,17 @@ var readRouteMeta = function(meta) {

/**
* @ngdoc method
* @name resetMeta
* @description
* Helper function to reset ngMeta data and apply defaults. Useful when setting up ngmeta data in a
* UI-router resolve function.
*
* @returns {Object} self
*/
var resetMeta = function() {
readRouteMeta();
return this;
};
/**

@@ -208,3 +222,4 @@ * @ngdoc method

'setTag': setTag,
'setDefaultTag': setDefaultTag
'setDefaultTag': setDefaultTag,
'resetMeta' : resetMeta
};

@@ -211,0 +226,0 @@ }

@@ -348,2 +348,61 @@ var SOME_TITLE = 'Hello';

describe('resetMeta: resetMeta()', function() {
describe('Basic checks', function() {
//Inject dependencies
beforeEach(function() {
injectDependencies();
});
it('should provide an resetMeta() function', function() {
expect(ngMeta.resetMeta).toBeDefined();
});
});
describe('Standard functionality', function() {
beforeEach(function() {
module(function(ngMetaProvider) {
ngMetaProvider.setDefaultTag(SOME_TAG, SOME_TAG_DEFAULT_VALUE);
});
injectDependencies();
ngMeta.init();
});
it('should set default values', function() {
ngMeta.resetMeta();
//default value available immediately
expect($rootScope.ngMeta[SOME_TAG]).toEqual(SOME_TAG_DEFAULT_VALUE);
// default value should still be present after state change
$rootScope.$broadcast('$stateChangeSuccess', { meta: { disableUpdate: true } });
expect($rootScope.ngMeta[SOME_TAG]).toEqual(SOME_TAG_DEFAULT_VALUE);
});
it('should overwrite a previous default value', function() {
ngMeta.resetMeta();
ngMeta.setTag(SOME_TAG, SOME_TAG_VALUE);
$rootScope.$broadcast('$stateChangeSuccess', { meta: { disableUpdate: true } });
expect($rootScope.ngMeta[SOME_TAG]).not.toEqual(SOME_TAG_DEFAULT_VALUE);
});
it('should not overwrite a previous default value if state does not include disableUpdate', function() {
ngMeta.resetMeta();
ngMeta.setTag(SOME_TAG, SOME_TAG_VALUE);
$rootScope.$broadcast('$stateChangeSuccess', { meta: { disableUpdate: false } });
expect($rootScope.ngMeta[SOME_TAG]).toEqual(SOME_TAG_DEFAULT_VALUE);
});
it('should overwrite a non-default value', function() {
ngMeta.resetMeta();
ngMeta.setTitle(SOME_TITLE);
$rootScope.$broadcast('$stateChangeSuccess', { meta: { disableUpdate: true } });
expect($rootScope.ngMeta[SOME_TAG]).toEqual(SOME_TAG_DEFAULT_VALUE);
expect($rootScope.ngMeta.title).toEqual(SOME_TITLE);
});
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc